我正在尝试添加使用Gravity Forms Product Add Ons设置的费用。费用来自产品变化,但我遇到了一些问题:
这是我到目前为止所做的:
// define the woocommerce_cart_item_subtotal callback
function filter_woocommerce_cart_item_subtotal(
$product, $cart_item, $cart_item_key) {
global $woocommerce;
// 1. Find out if Setup fee is added
$custom_setup_fee = get_post_meta($product->ID, 'value', true);
echo $custom_setup_fee;
/*
echo WC()->cart->get_product_subtotal(
$_product, $cart_item['quantity'] ), $cart_item, $cart_item_key;
echo WC()->cart->get_product_subtotal(
$_product, $cart_item['quantity'] );
*/
// 2. If setup fee added, add to existing value
// 3. If no setup fee just return value
return $product;
};
// add the filter
add_filter(
'woocommerce_cart_item_subtotal',
'filter_woocommerce_cart_item_subtotal', 10, 3);
第一个名为$custom_setup_fee
的变量不会引入任何内容。有什么想法吗?