summaryrefslogtreecommitdiff
path: root/class-wc-gnutaler-gateway.php
diff options
context:
space:
mode:
Diffstat (limited to 'class-wc-gnutaler-gateway.php')
-rw-r--r--class-wc-gnutaler-gateway.php56
1 files changed, 48 insertions, 8 deletions
diff --git a/class-wc-gnutaler-gateway.php b/class-wc-gnutaler-gateway.php
index 94b2e06..fe86503 100644
--- a/class-wc-gnutaler-gateway.php
+++ b/class-wc-gnutaler-gateway.php
@@ -9,7 +9,7 @@
* Plugin Name: GNU Taler Payment for WooCommerce
* Plugin URI: https://git.taler.net/woocommerce-taler
* Description: This plugin enables payments via the GNU Taler payment system
- * Version: 0.9.3
+ * Version: 0.9.4
* Author: Dominique Hofmann, Jan StrĂ¼bin, Christian Grothoff
* Author URI: https://taler.net/
*
@@ -790,11 +790,51 @@ function gnutaler_init_gateway_class() {
$shipping_address_street = '';
$shipping_address_street_nr = '';
- $store_address = $wc_order->get_shipping_address_1();
+ $store_address = $wc_order->get_shipping_address_1( $context = 'view' );
+ if ( is_null( $store_address ) || empty( $store_address ) )
+ $store_address = $wc_order->get_billing_address_1( $context = 'view' );
$store_address_inverted = strrev( $store_address );
$store_address_array = str_split( $store_address_inverted );
-
- // Split the address into street and street number.
+ $country = $wc_order->get_shipping_country ($context = 'view');
+ if ( is_null( $country ) || empty( $country ) )
+ $country = $wc_order->get_billing_country ($context = 'view');
+ $state = $wc_order->get_shipping_state ($context = 'view');
+ if ( is_null( $state ) || empty( $state ) )
+ $state = $wc_order->get_billing_state ($context = 'view');
+ $city = $wc_order->get_shipping_city ($context = 'view');
+ if ( is_null( $city ) || empty( $city ) )
+ $city = $wc_order->get_billing_city ($context = 'view');
+ $postcode = $wc_order->get_shipping_postcode ($context = 'view');
+ if ( is_null( $postcode ) || empty( $postcode ) )
+ $postcode = $wc_order->get_billing_postcode ($context = 'view');
+
+ $this->info (
+ sprintf(
+ 'Shipping address is %s - %s - %s - %s - %s',
+ $store_address,
+ $wc_order->get_shipping_country ($context = 'view'),
+ $wc_order->get_shipping_state ($context = 'view'),
+ $wc_order->get_shipping_city ($context = 'view'),
+ $wc_order->get_shipping_postcode ($context = 'view')) );
+
+ $this->info (
+ sprintf(
+ 'Billing address is %s - %s - %s - %s - %s',
+ $store_address,
+ $wc_order->get_billing_country ($context = 'view'),
+ $wc_order->get_billing_state ($context = 'view'),
+ $wc_order->get_billing_city ($context = 'view'),
+ $wc_order->get_billing_postcode ($context = 'view')) );
+ $this->info (
+ sprintf(
+ 'Using address is %s - %s - %s - %s - %s',
+ $store_address,
+ $country,
+ $state,
+ $city,
+ $postcode));
+
+ // Split the address into street and street number.
foreach ( $store_address_array as $char ) {
if ( ! $whitechar_encounter ) {
$shipping_address_street .= $char;
@@ -805,10 +845,10 @@ function gnutaler_init_gateway_class() {
}
}
$ret = array(
- 'country' => $wc_order->get_shipping_country(),
- 'country_subdivision' => $wc_order->get_shipping_state(),
- 'town' => $wc_order->get_shipping_city(),
- 'post_code' => $wc_order->get_shipping_postcode(),
+ 'country' => $country,
+ 'country_subdivision' => $state,
+ 'town' => $city,
+ 'post_code' => $postcode,
'street' => $shipping_address_street,
'building_number' => $shipping_address_street_nr,
);