📌  相关文章
📜  将自定义输入字段值保存到购物车项目中 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:33.183000             🧑  作者: Mango

代码示例1
// 3,5. Add fee ;)
 
add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_add_checkout_fee' );
   
function bbloomer_add_checkout_fee() {
   foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
        if (!empty( $cart_item['custom_text_add_on'] ) ) {
           WC()->cart->add_fee( 'Product Add-on fee', 55 );
            break;
        }
    }
}