diff --git a/assets/js/ledyer-checkout-for-woocommerce.js b/assets/js/ledyer-checkout-for-woocommerce.js
index fd963fb..0854c69 100644
--- a/assets/js/ledyer-checkout-for-woocommerce.js
+++ b/assets/js/ledyer-checkout-for-woocommerce.js
@@ -29,6 +29,8 @@ jQuery(function ($) {
ledyerUpdateNeeded: false,
shippingEmailExists: false,
shippingPhoneExists: false,
+ shippingFirstNameExists: false,
+ shippingLastNameExists: false,
/**
* Triggers on document ready.
@@ -164,6 +166,12 @@ jQuery(function ($) {
if (name === 'shipping_email') {
lco_wc.shippingEmailExists = true;
}
+ if (name === 'shipping_first_name') {
+ lco_wc.shippingFirstNameExists = true;
+ }
+ if (name === 'shipping_last_name') {
+ lco_wc.shippingLastNameExists = true;
+ }
$('p#' + name + '_field').appendTo('#lco-extra-checkout-fields');
} else {
$('input[name="' + name + '"]').closest('p').appendTo('#lco-extra-checkout-fields');
@@ -272,13 +280,19 @@ jQuery(function ($) {
'shipping_country' in data.shipping_address ? $('#shipping_country').val(data.shipping_address.shipping_country.toUpperCase()) : '';
'shipping_state' in data.shipping_address ? $('#shipping_state').val(data.shipping_address.shipping_state) : '';
- // extra shipping fields (email, phone).
+ // extra shipping fields (email, phone, name).
if (lco_wc.shippingEmailExists === true && $('#shipping_email')) {
$('#shipping_email').val((('shipping_email' in data.shipping_address) ? data.shipping_address.shipping_email : ''));
}
if (lco_wc.shippingPhoneExists === true && $('#shipping_phone')) {
$('#shipping_phone').val((('shipping_phone' in data.shipping_address) ? data.shipping_address.shipping_phone : ''));
}
+ if (lco_wc.shippingFirstNameExists === true && $('#shipping_first_name')) {
+ $('#shipping_first_name').val((('shipping_first_name' in data.shipping_address) ? data.shipping_address.shipping_first_name : ''));
+ }
+ if (lco_wc.shippingLastNameExists === true && $('#shipping_last_name')) {
+ $('#shipping_last_name').val((('shipping_last_name' in data.shipping_address) ? data.shipping_address.shipping_last_name : ''));
+ }
}
},
diff --git a/changelog.readme b/changelog.readme
index 9e76556..6050cd1 100644
--- a/changelog.readme
+++ b/changelog.readme
@@ -1,3 +1,6 @@
+## 1.5.0
+Feature: Show order recipient details in order overview
+
## 1.4.0
Feature: Allow custom shipping address contact details in settings
diff --git a/classes/admin/class-ledyer-meta-box.php b/classes/admin/class-ledyer-meta-box.php
index da7a720..ed3e891 100644
--- a/classes/admin/class-ledyer-meta-box.php
+++ b/classes/admin/class-ledyer-meta-box.php
@@ -93,10 +93,10 @@ public function print_standard_content( $ledyer_order ) {
-
+
-
+
diff --git a/classes/class-ledyer-ajax.php b/classes/class-ledyer-ajax.php
index 8221cf0..6f6cca1 100644
--- a/classes/class-ledyer-ajax.php
+++ b/classes/class-ledyer-ajax.php
@@ -186,14 +186,16 @@ public static function set_customer_data( $ledyer_order ) {
switch ( $key ) {
case 'billing_first_name':
- case 'shipping_first_name':
$fields['billing_address'][ $key ] = $ledyer_order['customer']['firstName'];
- $fields['shipping_address'][ $key ] = $ledyer_order['customer']['firstName'];
+ break;
+ case 'shipping_first_name':
+ $fields['shipping_address'][ $key ] = isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ? $ledyer_order['customer']['shippingAddress']['contact']['firstName'] : '';
break;
case 'billing_last_name':
- case 'shipping_last_name':
$fields['billing_address'][ $key ] = $ledyer_order['customer']['lastName'];
- $fields['shipping_address'][ $key ] = $ledyer_order['customer']['lastName'];
+ break;
+ case 'shipping_last_name':
+ $fields['shipping_address'][ $key ] = isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ? $ledyer_order['customer']['shippingAddress']['contact']['lastName'] : '';
break;
case 'billing_company':
$fields['billing_address'][ $key ] = isset( $ledyer_order['customer']['billingAddress'] ) ? $ledyer_order['customer']['billingAddress']['companyName'] : '';
@@ -231,6 +233,12 @@ public static function set_customer_data( $ledyer_order ) {
case 'billing_email':
$fields['billing_address'][ $key ] = $ledyer_order['customer']['email'];
break;
+ case 'shipping_phone':
+ $fields['shipping_address'][ $key ] = isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ? $ledyer_order['customer']['shippingAddress']['contact']['phone'] : '';
+ break;
+ case 'shipping_email':
+ $fields['shipping_address'][ $key ] = isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ? $ledyer_order['customer']['shippingAddress']['contact']['email'] : '';
+ break;
default:
unset( $fields[ $key ] );
break;
diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php
index 9340693..33459f8 100644
--- a/classes/class-ledyer-lco-gateway.php
+++ b/classes/class-ledyer-lco-gateway.php
@@ -66,8 +66,8 @@ public function __construct() {
\add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'show_thank_you_snippet' ) );
\add_action( 'woocommerce_thankyou', 'lco_unset_sessions', 100, 1 );
- \add_action('woocommerce_admin_order_data_after_billing_address', array( $this, 'ledyer_order_billing_fileds' ), 10, 1);
- \add_action('woocommerce_admin_order_data_after_shipping_address', array( $this, 'ledyer_order_shipping_fileds' ), 10, 1);
+ \add_action('woocommerce_admin_order_data_after_billing_address', array( $this, 'ledyer_order_billing_fields' ), 10, 1);
+ \add_action('woocommerce_admin_order_data_after_shipping_address', array( $this, 'ledyer_order_shipping_fields' ), 10, 1);
\add_filter('woocommerce_formatted_address_replacements', array( $this, 'change_order_fields' ), 10, 2);
}
@@ -304,15 +304,18 @@ public function process_payment_handler( $order_id ) {
$ledyer_country = wc_get_base_location()['country'];
update_post_meta( $order_id, '_wc_ledyer_country', $ledyer_country );
- // Set shipping phone and email.
- update_post_meta( $order_id, '_shipping_phone', sanitize_text_field( $ledyer_order['customer']['phone'] ) );
- update_post_meta( $order_id, '_shipping_email', sanitize_text_field( $ledyer_order['customer']['email'] ) );
-
// Set shipping meta
if( isset( $ledyer_order['customer']['shippingAddress'] ) ) {
update_post_meta( $order_id, '_shipping_attention_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['attentionName'] ) );
update_post_meta( $order_id, '_shipping_care_of', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['careOf'] ) );
}
+ // Set order recipient meta
+ if( isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ) {
+ update_post_meta( $order_id, '_shipping_first_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["firstName"] ) );
+ update_post_meta( $order_id, '_shipping_last_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["lastName"]) );
+ update_post_meta( $order_id, '_shipping_phone', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["phone"] ) );
+ update_post_meta( $order_id, '_shipping_email', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["email"]) );
+ }
// Set billing meta
if( isset( $ledyer_order['customer']['billingAddress'] ) ) {
@@ -426,7 +429,7 @@ public function wc_order_created( $order_id, $posted_data, $order ) {
*
* @return void
*/
- public function ledyer_order_billing_fileds( $order ) {
+ public function ledyer_order_billing_fields( $order ) {
if ( 'Automattic\WooCommerce\Admin\Overrides\Order' === get_class( $order ) ) {
$order_id = $order->get_id();
@@ -451,7 +454,7 @@ public function ledyer_order_billing_fileds( $order ) {
*
* @return void
*/
- public function ledyer_order_shipping_fileds( $order ) {
+ public function ledyer_order_shipping_fields( $order ) {
if ( 'Automattic\WooCommerce\Admin\Overrides\Order' === get_class( $order ) ) {
$order_id = $order->get_id();
@@ -461,6 +464,10 @@ public function ledyer_order_shipping_fileds( $order ) {
$attention_name = get_post_meta( $order_id, '_shipping_attention_name', true );
$care_of = get_post_meta( $order_id, '_shipping_care_of', true );
+ $first_name = get_post_meta( $order_id, '_shipping_first_name', true );
+ $last_name = get_post_meta( $order_id, '_shipping_last_name', true );
+ $phone = get_post_meta( $order_id, '_shipping_phone', true );
+ $email = get_post_meta( $order_id, '_shipping_email', true );
if ( ! empty( $attention_name ) ) {
echo '
' . __( 'Shipping Attention Name' ) . ':
' . esc_html($attention_name) . '
' . __( 'Shipping Care Of' ) . ':
' . esc_html($care_of) . '
' . __( 'Order Recipient Name' ) . ':
' . esc_html($first_name) . ' ' . esc_html($last_name) . '
' . __( 'Order Recipient Phone' ) . ':
' . esc_html($phone) . '
' . __( 'Order Recipient Email' ) . ':
' . esc_html($email) . '