admin管理员组文章数量:1302937
I want to get the value of a select attribute in the checkout page on WooCommerce, and then use it to show or not the delivery data.
I have tried everything but it still does not appear, the object of my products when I go through it comes out empty.
I have tried something similar to this to see what data I am getting but it comes out empty:
add_filter( 'woocommerce_cart_item_name', 'cart_variation_description', 20, 3);
function cart_variation_description( $name, $cart_item, $cart_item_key ) {
// Get the corresponding WC_Product
$product_item = $cart_item['data'];
if(!empty($product_item) && $product_item->is_type( 'variation' ) ) {
// WC 3+ compatibility
//$descrition = $product_item->get_description();
//$descrition = $product_item->get_attribute( 'pa_modo' );
$descrition = $product_item->get_post_meta( $variation->ID, 'price_1_50', true );
$result = __( 'Description: ', 'woocommerce' ) . $descrition;
return $name . '<br>' . $result;
} else
return $name;
}
Thanks a lot.
本文标签:
版权声明:本文标题:woocommerce offtopic - I want to get the value of a select attribute in the checkout page, and then use it to show or not the de 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741721490a2394415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论