Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix platform checkout store logo preview #4814

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-13-platform-checkout-brand-logo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix platform checkout store logo preview.
4 changes: 1 addition & 3 deletions client/components/file-upload/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* External dependencies
*/
import * as React from 'react';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies.
Expand All @@ -20,9 +19,8 @@ const FileUploadPreview = ( {
fileName,
showPreview,
}: FileUploadProps ): JSX.Element => {
let url =
const url =
wcpaySettings.restUrl + NAMESPACE.substring( 1 ) + '/file/' + fileName;
url = addQueryArgs( url, { as_account: 0 } );

return (
<>
Expand Down
2 changes: 0 additions & 2 deletions client/settings/express-checkout-settings/file-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ const PlatformCheckoutFileUpload: React.FunctionComponent< PlatformCheckoutFileU
const body = new FormData();
body.append( 'file', file );
body.append( 'purpose', purpose );
// Interpreting as_account as Boolean false in the backend
body.append( 'as_account', '0' );

try {
const uploadedFile: unknown = await apiFetch( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
* External dependencies
*/
import React from 'react';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies.
*/
import { NAMESPACE } from 'wcpay/data/constants';

export default ( { storeName, storeLogo, ...props } ) => {
let storeLogoUrl =
const storeLogoUrl =
wcpaySettings.restUrl + NAMESPACE.substring( 1 ) + '/file/' + storeLogo;
storeLogoUrl = addQueryArgs( storeLogoUrl, { as_account: 0 } );

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ public static function ajax_init_platform_checkout() {
'session_cookie_value' => wp_unslash( $_COOKIE[ $session_cookie_name ] ?? '' ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
'store_data' => [
'store_name' => get_bloginfo( 'name' ),
'store_logo' => ! empty( $store_logo ) ? add_query_arg( 'as_account', '0', get_rest_url( null, 'wc/v3/payments/file/' . $store_logo ) ) : '',
'store_logo' => ! empty( $store_logo ) ? get_rest_url( null, 'wc/v3/payments/file/' . $store_logo ) : '',
'custom_message' => self::get_gateway()->get_option( 'platform_checkout_custom_message' ),
'blog_id' => Jetpack_Options::get_option( 'id' ),
'blog_url' => get_site_url(),
Expand Down