小编Mar*_*med的帖子

如何计算 WooCommerce 编辑订单中的自定义订单总额?

目前,我正在开发 WooCommerce (5.2.2) 项目。我的客户希望在后端(不适用于客户)为预付款创建一个自定义输入字段,以便当我的客户收到客户的预付款(交货目的)时,他们可以手动添加并从后端订购总计自动调整。因此,我编写了代码并在帖子元表中创建了一个自定义字段,并使用该元表值来计算总订单,它可以工作,但我必须刷新两次才能获取订单的总新值。这是我的代码并告诉我如何修复它 -

add_action( 'manage_shop_order_posts_custom_column' ,  array(&$this,'add_custom_column_content'), 11, 2 );

add_action( 'woocommerce_admin_order_totals_after_discount', array(&$this, 'vp_add_sub_total'), 10, 1);

add_action( 'woocommerce_process_shop_order_meta', array(&$this, 'save_order_custom_field_meta_data'), 12, 2 );


// Output a custom editable field in backend edit order pages under general section
         function editable_order_custom_field( $order ){            
        
            // Get "Delivery Type" from meta data (not item meta data)
            $updated_advance_payment = $order->get_meta('_advance_payment');
        
            // Replace "Delivery Type" value by the meta data if it exist
            $advancePayment = $updated_advance_payment ? $updated_advance_payment : ( isset($item_value) ? $item_value : …
Run Code Online (Sandbox Code Playgroud)

wordpress woocommerce

3
推荐指数
1
解决办法
2023
查看次数

标签 统计

woocommerce ×1

wordpress ×1