我正在尝试手动向WooCommerce添加订单。除了加成费外,一切都很顺利。它不会在订单中增加费用:
$order = wc_create_order();
$order->add_product( 1, 2 ); // This is an existing SIMPLE product
$order->add_fee('discount', -10, true, 'standard' );
$order->calculate_totals();
$order->update_status("Processing", 'Order from mobile application', TRUE);因此,订单是添加的,但我不能添加一个fee(discount)到订单。
谢谢你提前提供帮助!)
发布于 2017-01-19 22:09:34
经过几个小时的研究和论坛,我找到了解决方案,一个工作。手动添加值为-10的订单项
$item_id = wc_add_order_item( $order->id, array(
'order_item_name' => "The discount",
'order_item_type' => 'fee'
) );
wc_add_order_item_meta( $item_id, '_line_total', wc_format_decimal( -10) );https://stackoverflow.com/questions/41736343
复制相似问题