我当前的代码如下:
function final_cart_update( $cart_object ) {
foreach ( $cart_object->get_cart() as $cart_item ) {
// get the custom pricing for this product
$pricing_custom = get_post_meta( $cart_item['product_id'], '_number_field_1', true );
// get product price
$price = floatval( $cart_item['data']->get_price() );
// set new price
$cart_item['data']->set_price( $price + $pricing_custom );
}
}
add_action( 'woocommerce_before_calculate_totals', 'final_cart_update', 99, 1 );
此→
$pricing_custom = get_post_meta( $cart_item['product_id'], '_number_field_1', true );
正在从中获取信息→ enter image description here
在前端,这是安排→ enter image description here
最终的结帐页面如下所示→ enter image description here
数学:
Variation Price: 49USD
Checkbox Price: 79USD
但是产品正在更新。我想要的是小计应该更新。
我尝试了这个钩子,但是它不起作用→
woocommerce_cart_product_subtotal
请指导我。
P.S.→。我是新来的,所以我无权嵌入图像。