Skip to content

Commit

Permalink
Merge pull request #41 from wuunder/development
Browse files Browse the repository at this point in the history
added switch support for destination billing/shipping
  • Loading branch information
TimD90 authored Feb 17, 2020
2 parents 3e90720 + 06be2c0 commit a249328
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Released


## [2.7.12](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.12) - 2020-02-17

### Added
- Support for WC switch destination address billing/shippinh

## [2.7.11](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.11) - 2020-01-21

### Added
Expand Down
39 changes: 29 additions & 10 deletions includes/parcelshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ function wcwp_parcelShopLocator()
if( ! empty( $_POST['address'] ) ) {
$shipping_address = sanitize_text_field($_POST['address']);
} else {
$shipping_address = '';
$shipping_address .= ( ! empty(WC()->customer->get_shipping_address() ) ? WC()->customer->get_shipping_address() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_city() ) ? WC()->customer->get_shipping_city() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_postcode() ) ? WC()->customer->get_shipping_postcode() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_country() ) ? WC()->customer->get_shipping_country() . ' ' : '' );

$dest_address = get_option( 'woocommerce_ship_to_destination' );
if ($dest_address === 'shipping') {
$shipping_address = '';
$shipping_address .= ( ! empty(WC()->customer->get_shipping_address() ) ? WC()->customer->get_shipping_address() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_city() ) ? WC()->customer->get_shipping_city() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_postcode() ) ? WC()->customer->get_shipping_postcode() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_country() ) ? WC()->customer->get_shipping_country() . ' ' : '' );
} else if ($dest_address === 'billing') {
$shipping_address = '';
$shipping_address .= ( ! empty(WC()->customer->get_billing_address() ) ? WC()->customer->get_billing_address() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_city() ) ? WC()->customer->get_billing_city() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_postcode() ) ? WC()->customer->get_billing_postcode() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_country() ) ? WC()->customer->get_billing_country() . ' ' : '' );
}
}

$connector = new Wuunder\Connector( $apiKey, $status == 'productie' ? false : true);
Expand Down Expand Up @@ -45,11 +55,20 @@ function wcwp_getAddress() {
if(!empty($_POST['address'])) {
$shipping_address = sanitize_text_field($_POST['address']);
} else {

$shipping_address .= (!empty(WC()->customer->get_shipping_address()) ? WC()->customer->get_shipping_address() . " " : "");
$shipping_address .= (!empty(WC()->customer->get_shipping_city()) ? WC()->customer->get_shipping_city() . " " : "");
$shipping_address .= (!empty(WC()->customer->get_shipping_postcode()) ? WC()->customer->get_shipping_postcode() . " " : "");
$shipping_address .= (!empty(WC()->customer->get_shipping_country()) ? WC()->customer->get_shipping_country() . " " : "");
$dest_address = get_option( 'woocommerce_ship_to_destination' );
if ($dest_address === 'shipping') {
$shipping_address = '';
$shipping_address .= ( ! empty(WC()->customer->get_shipping_address() ) ? WC()->customer->get_shipping_address() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_city() ) ? WC()->customer->get_shipping_city() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_postcode() ) ? WC()->customer->get_shipping_postcode() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_shipping_country() ) ? WC()->customer->get_shipping_country() . ' ' : '' );
} else if ($dest_address === 'billing') {
$shipping_address = '';
$shipping_address .= ( ! empty(WC()->customer->get_billing_address() ) ? WC()->customer->get_billing_address() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_city() ) ? WC()->customer->get_billing_city() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_postcode() ) ? WC()->customer->get_billing_postcode() . ' ' : '' );
$shipping_address .= ( ! empty(WC()->customer->get_billing_country() ) ? WC()->customer->get_billing_country() . ' ' : '' );
}
}

echo json_encode($shipping_address);
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-wuunder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Wuunder for-woocommerce
* Plugin URI: https://wearewuunder.com/wuunder-voor-webshops/
* Description: Wuunder shipping plugin
* Version: 2.7.11
* Version: 2.7.12
* Author: Wuunder
* Author URI: http://wearewuunder.com
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ class Woocommerce_Wuunder {
public static $plugin_path;
public static $plugin_basename;

const VERSION = '2.7.11';
const VERSION = '2.7.12';

public function __construct() {

Expand Down

0 comments on commit a249328

Please sign in to comment.