Fix onboarding email with spaces/plus signs.

Fix order item when image_url is empty.
This commit is contained in:
Pedro Silva 2023-09-08 10:32:34 +01:00
parent 53f82b74f3
commit a532462595
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 15 additions and 2 deletions

View file

@ -249,9 +249,12 @@ class Item {
'sku' => $this->sku(),
'category' => $this->category(),
'url' => $this->url(),
'image_url' => $this->image_url(),
);
if ( $this->image_url() ) {
$item['image_url'] = $this->image_url();
}
if ( $this->tax() ) {
$item['tax'] = $this->tax()->to_array();
}

View file

@ -211,7 +211,7 @@ class SettingsListener {
}
$merchant_id = sanitize_text_field( wp_unslash( $_GET['merchantIdInPayPal'] ) );
$merchant_email = sanitize_text_field( wp_unslash( $_GET['merchantId'] ) );
$merchant_email = $this->sanitize_onboarding_email( sanitize_text_field( wp_unslash( $_GET['merchantId'] ) ) );
$onboarding_token = sanitize_text_field( wp_unslash( $_GET['ppcpToken'] ) );
$retry_count = isset( $_GET['ppcpRetry'] ) ? ( (int) sanitize_text_field( wp_unslash( $_GET['ppcpRetry'] ) ) ) : 0;
// phpcs:enable WordPress.Security.NonceVerification.Missing
@ -278,6 +278,16 @@ class SettingsListener {
$this->onboarding_redirect();
}
/**
* Sanitizes the onboarding email.
*
* @param string $email The onboarding email.
* @return string
*/
private function sanitize_onboarding_email( string $email ): string {
return str_replace( ' ', '+', $email );
}
/**
* Redirect to the onboarding URL.
*