mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix GooglePay general fixes / improvements
This commit is contained in:
parent
d6a564f24f
commit
318217acb9
9 changed files with 85 additions and 41 deletions
|
@ -29,7 +29,7 @@ return array(
|
|||
$fields,
|
||||
'allow_card_button_gateway',
|
||||
array(
|
||||
'googlepay_button_enabled' => array(
|
||||
'googlepay_button_enabled' => array(
|
||||
'title' => __( 'Google Pay Button', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Google Pay button', 'woocommerce-paypal-payments' ),
|
||||
|
@ -44,14 +44,18 @@ return array(
|
|||
'handler' => 'SubElementsHandler',
|
||||
'options' => array(
|
||||
'values' => array( '1' ),
|
||||
'elements' => array( '#field-googlepay_button_color', '#field-googlepay_button_type' ),
|
||||
'elements' => array(
|
||||
'#field-googlepay_button_color',
|
||||
'#field-googlepay_button_type',
|
||||
'#field-googlepay_button_shipping_enabled',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'googlepay_button_color' => array(
|
||||
'googlepay_button_color' => array(
|
||||
'title' => str_repeat( ' ', 6 ) . __( 'Button Color', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
'label' => '',
|
||||
|
@ -63,7 +67,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
'requirements' => array(),
|
||||
),
|
||||
'googlepay_button_type' => array(
|
||||
'googlepay_button_type' => array(
|
||||
'title' => str_repeat( ' ', 6 ) . __( 'Button Type', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'select',
|
||||
'class' => array(),
|
||||
|
@ -74,6 +78,15 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
'requirements' => array(),
|
||||
),
|
||||
'googlepay_button_shipping_enabled' => array(
|
||||
'title' => str_repeat( ' ', 6 ) . __( 'Shipping Callback', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable Google Pay shipping callback', 'woocommerce-paypal-payments' ),
|
||||
'default' => 'no',
|
||||
'screens' => array( State::STATE_ONBOARDED ),
|
||||
'gateway' => 'paypal',
|
||||
'requirements' => array(),
|
||||
),
|
||||
)
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
.ppcp-button-googlepay {
|
||||
margin: 5px 0;
|
||||
margin: 7px 0;
|
||||
overflow: hidden;
|
||||
min-height: 40px;
|
||||
height: 45px;
|
||||
|
||||
&.ppcp-button-pill {
|
||||
|
@ -15,14 +16,31 @@
|
|||
|
||||
.woocommerce-checkout {
|
||||
.ppcp-button-googlepay {
|
||||
margin: 0;
|
||||
border-radius: 18px;
|
||||
height: 38px;
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.wp-block-woocommerce-cart, .wp-block-woocommerce-checkout {
|
||||
.ppcp-button-googlepay {
|
||||
margin: 0;
|
||||
.ppcp-has-googlepay-block {
|
||||
|
||||
.wp-block-woocommerce-checkout {
|
||||
.ppcp-button-googlepay {
|
||||
margin: 0;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.wp-block-woocommerce-cart {
|
||||
.ppcp-button-googlepay {
|
||||
margin: 0;
|
||||
height: 40px;
|
||||
}
|
||||
/* Workaround for blocks grid */
|
||||
.wc-block-components-express-payment__event-buttons {
|
||||
display: block;
|
||||
li[id*="express-payment-method-ppcp-"] {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -126,6 +126,8 @@ class GooglepayButton {
|
|||
const paymentDataRequest = await this.paymentDataRequest();
|
||||
console.log('[GooglePayButton] onButtonClick: paymentDataRequest', paymentDataRequest, this.context);
|
||||
|
||||
window.ppcpFundingSource = 'googlepay'; // TODO : do this on another place like on create order
|
||||
|
||||
this.paymentsClient.loadPaymentData(paymentDataRequest);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,13 @@ const GooglePayComponent = () => {
|
|||
manager.init();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const bodyClass = 'ppcp-has-googlepay-block';
|
||||
if (!document.body.classList.contains(bodyClass)) {
|
||||
document.body.classList.add(bodyClass);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Load GooglePay SDK
|
||||
loadCustomScript({ url: buttonConfig.sdk_url }).then(() => {
|
||||
|
@ -44,7 +51,7 @@ const GooglePayComponent = () => {
|
|||
}, [paypalLoaded, googlePayLoaded]);
|
||||
|
||||
return (
|
||||
<div id={buttonConfig.button.wrapper.replace('#', '')}></div>
|
||||
<div id={buttonConfig.button.wrapper.replace('#', '')} className="ppcp-button-googlepay"></div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class Button implements ButtonInterface {
|
|||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
private function add_onboarding_options( $options ): string {
|
||||
public function add_onboarding_options( $options ): string {
|
||||
$checked = '';
|
||||
try {
|
||||
$onboard_with_apple = $this->settings->get( 'ppcp-onboarding-apple' );
|
||||
|
@ -162,7 +162,7 @@ class Button implements ButtonInterface {
|
|||
* @param array $data The referrals data.
|
||||
* @return array
|
||||
*/
|
||||
private function add_partner_referrals_data( array $data ): array {
|
||||
public function add_partner_referrals_data( array $data ): array {
|
||||
try {
|
||||
$onboard_with_google = $this->settings->get( 'ppcp-onboarding-google' );
|
||||
if ( ! wc_string_to_bool( $onboard_with_google ) ) {
|
||||
|
@ -326,10 +326,8 @@ class Button implements ButtonInterface {
|
|||
*/
|
||||
private function googlepay_button(): void {
|
||||
?>
|
||||
<div class="ppc-button-wrapper">
|
||||
<div id="ppc-button-googlepay-container" class="ppcp-button-googlepay">
|
||||
<?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?>
|
||||
</div>
|
||||
<div id="ppc-button-googlepay-container" class="ppcp-button-googlepay">
|
||||
<?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue