Skip to content

Commit

Permalink
Fixed Afterpay for virtual products
Browse files Browse the repository at this point in the history
  • Loading branch information
gpressutto5 committed May 15, 2024
1 parent c0033b4 commit c905344
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/fix-afterpay-virtual-produts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Fixed Afterpay for virtual products that was not released yet


10 changes: 8 additions & 2 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4468,8 +4468,14 @@ private function handle_afterpay_shipping_requirement( WC_Order $order, Create_A
}

$billing_data = $this->order_service->get_billing_data_from_order( $order );
if ( $check_if_usable( $billing_data['address'] ) ) {
$request->set_shipping( $billing_data );
// Afterpay fails if we send more parameters than expected in the shipping address.
// This ensures that we only send the name and address fields, as in get_shipping_data_from_order.
$shipping_data = [
'name' => $billing_data['name'] ?? '',
'address' => $billing_data['address'] ?? [],
];
if ( $check_if_usable( $shipping_data['address'] ) ) {
$request->set_shipping( $shipping_data );
return;
}

Expand Down

0 comments on commit c905344

Please sign in to comment.