I have added product permalink on admin order page using the below code:
function fpd_custom_order_item_values1($item_id, $item,$product) {
global $post_id;
if (!empty( $product->get_id())){
$url = get_permalink( $product->get_id() );
$itemdata = array($product->get_sku(), $post_id,$url);
echo '<p>' . implode('_', $itemdata) . '</p>';
}
}
add_action( 'woocommerce_before_order_itemmeta', 'fpd_custom_order_item_values1', 100, 3);
This is throwing up this error when the order contains flat rate shipping:
Uncaught Error: Call to a member function get_id() on null
However, when there is no shipping in order, the code works fine. I have enclosed the code in this if condition if (!empty( $product->get_id())){
but the error is still there. How to resolve this error?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745265785a4619446.html
评论列表(0条)