• Resolved rkasutan

    (@rkasutan)


    Hello
    I have an issue with your module and the delivery plugin for Mondial Relay. In this delivery plugin, the WooCommerce Hook “woocommerce_checkout_update_order_meta” is called to save custom fields in the order. It works well with others payment methods (Stripe, PayPal standard, other PayPal plugins) but not with your plugin. It seems like the hook is not called at all when the payment is made with your plugin.
    Can you check this issue please ?
    Thank you for your help.
    Rodolphe

Viewing 11 replies - 1 through 11 (of 11 total)
  • dahive

    (@dahive)

    Hi,

    Same problem here.

    Thanks for your help.

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan & @dahive,

    As we don’t have the delivery plugin you mentioned with us we checked with custom snippet and call to the hook “woocommerce_checkout_update_order_meta” was successful. Can you please try changing the priority of the hook call in the delivery plugin and check?

    Thread Starter rkasutan

    (@rkasutan)

    Hello
    Thank you for your answer.
    You are right, this hook is called with your plugin. I have continued the analysis of this incompatibility and the problem seems to lie with the data contained in the $POST, or to be more precise the absence of data in the $POST.
    The plugin Mondial Relay adds HTML fields in the checkout page to store some data (like the code of the relay point chosen by the client). With the Hook “woocommerce_checkout_update_order_meta”, the plugin store those values in the custom fields of the order. To do that, it uses the $POST :

    if ($_POST[‘mrwp_parcel_shop_id’]) {
    update_post_meta($order_id, ‘Mondial Relay Parcel Shop ID’, sanitize_text_field($_POST[‘mrwp_parcel_shop_id’]));
    }

    It seems that when the “woocommerce_checkout_update_order_meta” Hook is called, the $POST does not contain those datas anymore with your payment method (It works well with other payments method).
    Do you know why this happens ?
    Thank you for your help.
    Rodolphe

    • This reply was modified 3 years ago by rkasutan.
    Thread Starter rkasutan

    (@rkasutan)

    Hello
    Have you check my last post ?
    Thank you
    Rodolphe

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan,

    Sorry for the delayed response. We are looking into it. We will get back to you as soon as we arrive at a solution.

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan,

    Apologies for the delay. We have released a new plugin update with the issue fixed. Can you please update the plugin to the latest version and try?

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan,

    You can save the form field values added by the plugin ‘Mondial Relay’ just like we saved ‘mr ap_parcel shop_id’ as the custom field in the below snippet

    add_action('wt_woocommerce_checkout_order_created', 'wt_woocommerce_checkout_order_created', 10, 2);
    
    function wt_woocommerce_checkout_order_created($order, $checkout_post){ 
    	
    	if(!empty($order)){
    		$id = method_exists($order, 'get_id') ? $order->get_id() : $order->id;
    		if(isset($checkout_post['mrwp_parcel_shop_id']) && !empty($checkout_post['mrwp_parcel_shop_id'])){
    			update_post_meta( $id, 'mrwp_parcel_shop_id', $checkout_post['mrwp_parcel_shop_id']);
    		}
    	}
    }
    Thread Starter rkasutan

    (@rkasutan)

    Hello
    Sorry for the late reply (I hope this thread is still open).
    First of all, thanks for your modification and your snippet, it is working. I can now save the data I need in the command custom fields. I had some hard times to make it work, but I had problems on my side too. Everything is now OK for this part.

    Unfortunatly, I have another issue with your plugin. I also need to change the expedition address of the command in WooCommerce (‘_shipping_company’, ‘_shipping_address_1’, ‘_shipping_address_2’, ‘_shipping_postcode’, ‘_shipping_city’ and ‘_shipping_country`). For the moment I can’t and I have found why. Your plugin is updating this address very late in the process and I can’t change this address after your change. It is made on line 1372 in this file :
    express-checkout-paypal-payment-gateway-for-woocommerce/includes/class-paypal-express-api.php
    Can you add a Hook for me to act after your change or a Filter so that I can change the address you will use ?
    Thank You for your help
    Rodolphe

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan,

    Our plugin uses the hook woocommerce_checkout_order_processed to change the address. Below is a sample code that uses this hook.

    add_action('woocommerce_checkout_order_processed', 'wt_paypal_address_override', 10, 3);
    
    function wt_paypal_address_override($order_id, $checkout_post, $order){
    	$billing_details = array("first_name" => "your-first-name",
    							 "last_name" => "your-last-name",
    							 "address_1" => "your-address-1",
    							);
    	$order->set_address($billing_details, 'billing');
    
    }

    Please note that the skip review option has to be enabled for this to work.

    Thread Starter rkasutan

    (@rkasutan)

    Hello
    It is finally working.
    Thank you for all your support.
    Best Regards
    Rodolphe

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rkasutan,

    Glad to hear that it’s working now.

    If you like the plugin and support, please leave us a review here. It would really help us spread the word.

    Thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Hook “woocommerce_checkout_update_order_meta” not called’ is closed to new replies.