updating woocommerce order in checkout page instead to create a new one

前端 未结 3 1766
野的像风
野的像风 2021-01-16 06:23

I am creating a Wordpress and WooCommerce plugin which does the following:

  1. An anonymous user customizes a product on the page
  2. In a php script in the
3条回答
  •  春和景丽
    2021-01-16 06:58

    Finally the solution is to update the values once the order has been made in the "thankyou.php" WooCommerce page.

    Are updated as follows:

    $item = $order->get_items('line_item');
    $data = (array) WC()->session->get('_lm_product_data');
    
    wc_update_order_item_meta(key($item), __( 'Name', 'hpwallart' ), $data['_name'] );
    wc_update_order_item_meta(key($item), __( 'Width', 'hpwallart' ), $data['_width'] );
    wc_update_order_item_meta(key($item), __( 'Height', 'hpwallart' ), $data['_height'] );
    

    Previously, in a step of the process, I have kept in the session variable "_lm_product_data" information that interests me for the last step.

提交回复
热议问题