mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge branch 'trunk' into PCP-951-could-not-retrieve-order
This commit is contained in:
commit
c654786ee3
11 changed files with 66 additions and 37 deletions
|
@ -59,9 +59,9 @@ class CheckoutActionHandler {
|
|||
);
|
||||
} else {
|
||||
errorHandler.clear();
|
||||
if (data.data.errors.length > 0) {
|
||||
if (data.data.errors?.length > 0) {
|
||||
errorHandler.messages(data.data.errors);
|
||||
} else if (data.data.details.length > 0) {
|
||||
} else if (data.data.details?.length > 0) {
|
||||
errorHandler.message(data.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
|
||||
} else {
|
||||
errorHandler.message(data.data.message, true);
|
||||
|
|
|
@ -233,8 +233,14 @@ class CreditCardRenderer {
|
|||
this.spinner.unblock();
|
||||
this.errorHandler.clear();
|
||||
|
||||
if (err.details?.length) {
|
||||
if (err.data?.details?.length) {
|
||||
this.errorHandler.message(err.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
|
||||
} else if (err.details?.length) {
|
||||
this.errorHandler.message(err.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
|
||||
} else if (err.data?.errors?.length > 0) {
|
||||
this.errorHandler.messages(err.data.errors);
|
||||
} else if (err.data?.message) {
|
||||
this.errorHandler.message(err.data.message, true);
|
||||
} else if (err.message) {
|
||||
this.errorHandler.message(err.message, true);
|
||||
} else {
|
||||
|
|
|
@ -27,10 +27,13 @@ class CheckoutFormValidator extends WC_Checkout {
|
|||
public function validate( array $data ) {
|
||||
$errors = new WP_Error();
|
||||
|
||||
if ( isset( $data['terms-field'] ) ) {
|
||||
// WC checks this field via $_POST https://github.com/woocommerce/woocommerce/issues/35328 .
|
||||
$_POST['terms-field'] = $data['terms-field'];
|
||||
// Some plugins check their fields using $_POST,
|
||||
// also WC terms checkbox https://github.com/woocommerce/woocommerce/issues/35328 .
|
||||
foreach ( $data as $key => $value ) {
|
||||
$_POST[ $key ] = $value;
|
||||
}
|
||||
// And we must call get_posted_data because it handles the shipping address.
|
||||
$data = $this->get_posted_data();
|
||||
|
||||
// It throws some notices when checking fields etc., also from other plugins via hooks.
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
|
|
|
@ -56,15 +56,6 @@ return array(
|
|||
return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+
|
||||
},
|
||||
|
||||
'compat.gzd.tracking_statuses_map' => function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'draft' => 'ON_HOLD',
|
||||
'processing' => 'SHIPPED',
|
||||
'shipped' => 'SHIPPED',
|
||||
'delivered' => 'DELIVERED',
|
||||
);
|
||||
},
|
||||
|
||||
'compat.module.url' => static function ( ContainerInterface $container ): string {
|
||||
/**
|
||||
* The path cannot be false.
|
||||
|
|
|
@ -130,20 +130,13 @@ class CompatModule implements ModuleInterface {
|
|||
$logger = $c->get( 'woocommerce.logger.woocommerce' );
|
||||
assert( $logger instanceof LoggerInterface );
|
||||
|
||||
$status_map = $c->get( 'compat.gzd.tracking_statuses_map' );
|
||||
|
||||
add_action(
|
||||
'woocommerce_gzd_shipment_after_save',
|
||||
static function( Shipment $shipment ) use ( $endpoint, $logger, $status_map ) {
|
||||
'woocommerce_gzd_shipment_status_shipped',
|
||||
static function( int $shipment_id, Shipment $shipment ) use ( $endpoint, $logger ) {
|
||||
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$gzd_shipment_status = $shipment->get_status();
|
||||
if ( ! array_key_exists( $gzd_shipment_status, $status_map ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$wc_order = $shipment->get_order();
|
||||
if ( ! is_a( $wc_order, WC_Order::class ) ) {
|
||||
return;
|
||||
|
@ -156,7 +149,7 @@ class CompatModule implements ModuleInterface {
|
|||
|
||||
$tracking_data = array(
|
||||
'transaction_id' => $transaction_id,
|
||||
'status' => (string) $status_map[ $gzd_shipment_status ],
|
||||
'status' => 'SHIPPED',
|
||||
);
|
||||
|
||||
$provider = $shipment->get_shipping_provider();
|
||||
|
@ -169,17 +162,17 @@ class CompatModule implements ModuleInterface {
|
|||
|
||||
$tracking_data['tracking_number'] = $tracking_information['tracking_number'] ?? '';
|
||||
|
||||
if ( $shipment->has_tracking() ) {
|
||||
if ( $shipment->get_tracking_id() ) {
|
||||
$tracking_data['tracking_number'] = $shipment->get_tracking_id();
|
||||
}
|
||||
|
||||
! $tracking_information ? $endpoint->add_tracking_information( $tracking_data, $wc_order->get_id() ) : $endpoint->update_tracking_information( $tracking_data, $wc_order->get_id() );
|
||||
} catch ( Exception $exception ) {
|
||||
$logger->error( "Couldn't sync tracking information: " . $exception->getMessage() );
|
||||
$shipment->add_note( "Couldn't sync tracking information: " . $exception->getMessage() );
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
},
|
||||
500,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ return array(
|
|||
CreditCardGateway::ID,
|
||||
PayUponInvoiceGateway::ID,
|
||||
CardButtonGateway::ID,
|
||||
OXXOGateway::ID .
|
||||
OXXOGateway::ID,
|
||||
Settings::PAY_LATER_TAB_ID,
|
||||
),
|
||||
true
|
||||
|
|
|
@ -81,12 +81,12 @@ class OXXO {
|
|||
add_filter(
|
||||
'woocommerce_thankyou_order_received_text',
|
||||
/**
|
||||
* Order can be null.
|
||||
* Param types removed to avoid third-party issues.
|
||||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function( string $message, $order ) {
|
||||
if ( ! $order instanceof WC_Order ) {
|
||||
function( $message, $order ) {
|
||||
if ( ! is_string( $message ) || ! $order instanceof WC_Order ) {
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,16 @@ class OXXO {
|
|||
|
||||
add_action(
|
||||
'woocommerce_email_before_order_table',
|
||||
function ( WC_Order $order, bool $sent_to_admin ) {
|
||||
/**
|
||||
* Param types removed to avoid third-party issues.
|
||||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function ( $order, $sent_to_admin ) {
|
||||
if ( ! is_a( $order, WC_Order::class ) || ! is_bool( $sent_to_admin ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
! $sent_to_admin
|
||||
&& $order->get_payment_method() === OXXOGateway::ID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue