Last active
October 24, 2024 07:21
-
-
Save webtoffee-git/7dc77857b68526a1dfa0d91d9dc7848e to your computer and use it in GitHub Desktop.
Code snippet for Colissimo plugin compatibility with the WebToffee PayPal plugin to include pickup details in the shipping address of order - By WebToffee (Paypal Payment Gateway plugin - Basic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do not copy this line of code | |
add_action("wt_woocommerce_checkout_order_created", "wt_woocommerce_checkout_order_creat", 10, 2); | |
function wt_woocommerce_checkout_order_creat($order, $checkout_post){ | |
$obj = new LpcPickupSelection(); | |
if (!$order->has_shipping_method('lpc_relay')) { | |
return; | |
} | |
$shipping = array(); | |
$pickupData = $obj->getCurrentPickUpLocationInfo(); | |
if(isset($pickupData['adresse1']) && !empty($pickupData['adresse1'])){ | |
$shipping['address_1'] = $pickupData['adresse1']; | |
WC()->session->post_data['shipping_address_1'] = $shipping['address_1']; | |
} | |
if(isset($pickupData['adresse2']) && !empty($pickupData['adresse2'])){ | |
$shipping['address_2'] = $pickupData['adresse2']; | |
WC()->session->post_data['shipping_address_2'] = $shipping['address_2']; | |
} | |
if(isset($pickupData['codePostal']) && !empty($pickupData['codePostal'])){ | |
$shipping['postcode'] = $pickupData['codePostal']; | |
WC()->session->post_data['shipping_postcode'] = $shipping['postcode']; | |
} | |
if(isset($pickupData['localite']) && !empty($pickupData['localite'])){ | |
$shipping['city'] = $pickupData['localite']; | |
WC()->session->post_data['shipping_city'] = $shipping['city']; | |
} | |
if(isset($pickupData['codePays']) && !empty($pickupData['codePays'])){ | |
$shipping['country'] = $pickupData['codePays']; | |
WC()->session->post_data['shipping_country'] = $shipping['country']; | |
} | |
if(!empty($shipping)){ | |
$order->set_address($shipping, 'shipping'); | |
} | |
} | |
add_filter("wt_shipping_address_create_order", "wt_shipping_addresss_create_order", 10, 2); | |
function wt_shipping_addresss_create_order($address, $order_id){ | |
if(!empty($order_id)){ | |
if($order = wc_get_order($order_id)){ | |
$address['SHIPTONAME'] = $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name(); | |
$address['SHIPTOSTREET'] = $order->get_shipping_address_1(); | |
$address['SHIPTOSTREET2'] = $order->get_shipping_address_2(); | |
$address['SHIPTOCITY'] = $order->get_shipping_city(); | |
$address['SHIPTOSTATE'] = $order->get_shipping_state(); | |
$address['SHIPTOZIP'] = $order->get_shipping_postcode(); | |
$address['SHIPTOCOUNTRYCODE'] = $order->get_shipping_country(); | |
$address['SHIPTOPHONENUM'] = $order->get_billing_phone(); | |
$address['NOTETEXT'] = $order->get_customer_note(); | |
$address['EMAIL'] = $order->get_billing_email(); | |
$address['PAYMENTREQUESTID'] = $order_id; | |
} | |
} | |
return $address; | |
} | |
add_filter("wt_force_send_shipping_address", "__return_true"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment