Skip to content

Commit

Permalink
Creating the customer for an order in DK using separate HTTP calls
Browse files Browse the repository at this point in the history
This is because DK can't take in payment terms, payment methods and ledger codes in the same call as the order.
  • Loading branch information
aldavigdis committed Jul 4, 2024
1 parent f22cda2 commit 91e8973
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Export/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace NineteenEightyFour\NineteenEightyWoo\Export;

use Automattic\WooCommerce\Admin\API\Customers;
use NineteenEightyFour\NineteenEightyWoo\Brick\Math\BigDecimal;
use NineteenEightyFour\NineteenEightyWoo\Service\DKApiRequest;
use NineteenEightyFour\NineteenEightyWoo\Config;
Expand Down Expand Up @@ -134,13 +135,12 @@ public static function to_dk_order_body( WC_Order $wc_order ): array {
$customer_array['Number'] = OrderHelper::get_kennitala( $wc_order );

if ( ! ExportCustomer::is_in_dk( OrderHelper::get_kennitala( $wc_order ) ) ) {
$customer_array['Name'] = $wc_order->get_formatted_billing_full_name();
$customer_array['Address1'] = $wc_order->get_billing_address_1();
$customer_array['Address2'] = $wc_order->get_billing_address_2();
$customer_array['City'] = $wc_order->get_billing_city();
$customer_array['ZipCode'] = $wc_order->get_billing_postcode();
$customer_array['Phone'] = $wc_order->get_billing_phone();
$customer_array['Email'] = $wc_order->get_billing_email();
if ( 0 === $wc_order->get_customer_id() ) {
Customer::create_in_dk_from_order( $wc_order );
} else {
$wc_customer = new WC_Customer( $wc_order->get_customer_id() );
Customer::create_in_dk( $wc_customer );
}
}

$recipient_array['Name'] = $wc_order->get_formatted_billing_full_name();
Expand All @@ -152,10 +152,6 @@ public static function to_dk_order_body( WC_Order $wc_order ): array {

$store_location = wc_get_base_location();

if ( $wc_order->get_billing_country() !== $store_location['country'] ) {
$customer_array['Country'] = $wc_order->get_billing_country();
}

if ( $wc_order->get_shipping_country() !== $store_location['country'] ) {
$recipient_array['Country'] = $wc_order->get_shipping_country();
}
Expand Down

0 comments on commit 91e8973

Please sign in to comment.