admin管理员组文章数量:1417463
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?
本文标签: phpAdding product permalink on admin order page throwing error
版权声明:本文标题:php - Adding product permalink on admin order page throwing error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745265784a2650591.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论