我试图创建一个订单,然后向其添加产品,效果很好。现在,我尝试在添加产品之前编辑产品的价格和名称。但是由于某种原因,我无法做到这一点
以下是我想做的事情:
$order = wc_create_order();
 $item = wc_get_product( $components[$comp]['component_product_id_2'] );
 //var_dump($item); exit;
/*_____BELOW IS WHAT I HAVE TRIED NEW_________*/                                 
 $item_args = array(
          'name'         => 'Product A',
          'total'        => wc_get_price_excluding_tax( $item, array( 'qty' => 1, 'price' => 245 ) ),
          );
 /*_____ABOVE IS WHAT I HAVE TRIED NEW_________*/ 
 $order->add_product(  $item, $components[$comp]['quantity'], $item_args );
                    版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
$prices = array( 'totals' => array( 
                'subtotal' => $custom_price, 
                'total' => $custom_price
            ) );
$order->add_product($product, $quantity, $prices);