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

PISHPS-368: Hide cart apple pay option #867

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ export default class MollieApplePayPaymentMethod extends Plugin {
this.hideApplePay('.payment-method-input.applepay');

// support for >= Shopware 6.4
// we have to find the dynamic ID and use that
// one as a selector to hide it
const client = new HttpClient();
client.get(
shopUrl + '/mollie/apple-pay/applepay-id',
(data) => {
me.hideApplePay('#paymentMethod' + data.id);
}
);

this.hideApplePay('#paymentMethod' + this.options.applePayId)

// hide cart apple pay select option
if (this.options.hideApplePayOption) {
this.hideApplePaySelect(this.options.applePayId);
}
}

/**
Expand All @@ -50,6 +45,15 @@ export default class MollieApplePayPaymentMethod extends Plugin {
}
}

/**
*
* @param applePayId
*/
hideApplePaySelect(applePayId) {
const option = document.querySelector('option[value="' + applePayId + '"]');
option.remove();
}

/**
*
* @returns {*}
Expand Down Expand Up @@ -107,4 +111,4 @@ export default class MollieApplePayPaymentMethod extends Plugin {
return null;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
{% if mollie_applepay_enabled %}
<div id="mollie_hide_applepay" data-mollie-template-applepay-account data-mollie-apple-pay-payment-method-options="{{ {
shopUrl: seoUrl('frontend.home.page'),
hideAlways: true
hideAlways: true,
applePayId: apple_pay_payment_method_id,
hideApplePayOption: false
}
|json_encode }}"></div>
{% endif %}
Expand Down Expand Up @@ -78,4 +80,4 @@
{% endblock %}

{{ parent() }}
{% endblock %}
{% endblock %}
14 changes: 14 additions & 0 deletions src/Resources/views/storefront/page/checkout/cart/index.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{% sw_extends '@Storefront/storefront/page/checkout/cart/index.html.twig' %}

{% block page_checkout_cart %}
{% if mollie_applepay_enabled %}
<div id="mollie_hide_applepay" data-mollie-template-applepay-account data-mollie-apple-pay-payment-method-options="{{ {
shopUrl: seoUrl('frontend.home.page'),
hideAlways: true,
applePayId: apple_pay_payment_method_id,
hideApplePayOption: true
}
|json_encode }}"></div>
{% endif %}

{{ parent() }}
{% endblock %}

{% block page_checkout_cart_shipping_costs_form_group_payment_method %}
<div class="form-group">
<label for="paymentMethodId">{{ "checkout.paymentMethod"|trans|sw_sanitize }}</label>
Expand Down
3 changes: 3 additions & 0 deletions src/Subscriber/ApplePayDirectSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void

$shoPhoneNumberField = $settings->isPhoneNumberFieldRequired() || $settings->isPhoneNumberFieldShown();

$applePayPaymentMethodId = $this->applePay->getActiveApplePayID($event->getSalesChannelContext());

$event->setParameter('mollie_applepaydirect_phonenumber_required', (int)$shoPhoneNumberField);
$event->setParameter('mollie_applepaydirect_enabled', $applePayDirectEnabled);
$event->setParameter('mollie_applepaydirect_restrictions', $settings->getRestrictApplePayDirect());
$event->setParameter('mollie_express_required_data_protection', $settings->isRequireDataProtectionCheckbox() && $event->getSalesChannelContext()->getCustomer() == null);
$event->setParameter('apple_pay_payment_method_id', $applePayPaymentMethodId);
}
}
Loading