Skip to content

Commit ef9d167

Browse files
Merge pull request #31 from michielgerritsen/release
Release
2 parents 1297014 + 240a508 commit ef9d167

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

src/Mollie_HyvaCompatibility/view/frontend/layout/hyva_checkout_cart_index.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class="Mollie\Payment\Block\Applepay\Shortcut\Button"
1212
name="mollie_cart_script"
1313
after="checkout.cart.methods.bottom"
14+
ifconfig="payment/mollie_methods_applepay/active"
1415
/>
1516
</referenceContainer>
1617
</body>

src/Mollie_HyvaCompatibility/view/frontend/layout/hyva_default.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
<referenceContainer name="cart-drawer.bottom">
99
<block template="Mollie_Payment::applepay/minicart/applepay-button-script.phtml"
1010
class="Mollie\Payment\Block\Applepay\Shortcut\Button"
11-
name="mollie_cart_script"/>
11+
name="mollie_cart_script"
12+
ifconfig="payment/mollie_methods_applepay/active"
13+
/>
1214
</referenceContainer>
1315
</body>
1416
</page>

src/Mollie_HyvaCompatibility/view/frontend/templates/Mollie_Payment/applepay/minicart/applepay-button-script.phtml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ use Magento\Framework\Escaper;
4949
},
5050

5151
pay: () => {
52-
// The $block total is more reliable as it holds shipping costs and discounts, but due to some setups
53-
// it is sometimes empty. In that case, use the totalAmount from the browser storage.
54-
// The correct total amount is retrieved and set during the shipping step.
55-
const amount = "<?= $escaper->escapeJs($block->getBaseGrandTotal()); ?>" || this.totalAmount;
52+
const amount = this.totalAmount;
5653
let countryCode, postalCode, shippingMethods, selectedShippingMethod, quoteTotals;
5754

5855
const request = {
@@ -82,19 +79,28 @@ use Magento\Framework\Escaper;
8279
let session = new ApplePaySession(3, request);
8380

8481
const getTotal = () => {
85-
let totals = [...quoteTotals];
86-
let total = totals.pop();
82+
const total = quoteTotals.find(item => item.code === 'grand_total') || quoteTotals[quoteTotals.length - 1];
8783

8884
total.label = "<?= $escaper->escapeJs($block->getStoreName()); ?>";
8985

90-
return total;
86+
const payload = { total };
87+
window.dispatchEvent(new CustomEvent('mollie-applepay-total', {
88+
detail: payload,
89+
}));
90+
91+
return payload.total;
9192
};
9293

9394
const getLineItems = () => {
9495
let totals = [...quoteTotals];
95-
totals.pop();
96+
totals = totals.filter(item => item.code !== 'grand_total');
97+
98+
const payload = { lineItems: totals };
99+
window.dispatchEvent(new CustomEvent('mollie-applepay-lineitems', {
100+
detail: payload,
101+
}));
96102

97-
return totals;
103+
return payload.lineItems;
98104
};
99105

100106
const handleAjaxError = (message) => {

src/Mollie_HyvaCompatibility/view/frontend/templates/Mollie_Payment/product/view/applepay.phtml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,30 @@ $product = $block->getProduct();
7878

7979
const getLineItems = () => {
8080
let totals = [...quoteTotals];
81-
totals.pop();
81+
totals = totals.filter(item => item.code !== 'grand_total');
8282

83-
return totals;
83+
const payload = { lineItems: totals };
84+
window.dispatchEvent(new CustomEvent('mollie-applepay-lineitems', {
85+
detail: payload,
86+
}));
87+
88+
return payload.lineItems;
8489
}
8590

8691
const getTotal = () => {
87-
let totals = [...quoteTotals];
88-
89-
var total = totals.pop();
92+
const total = quoteTotals.find(item => item.code === 'grand_total') || quoteTotals[quoteTotals.length - 1];
9093

9194
total.label = storeName;
9295

93-
return total;
96+
const payload = { total };
97+
window.dispatchEvent(new CustomEvent('mollie-applepay-total', {
98+
detail: payload,
99+
}));
100+
101+
return payload.total;
94102
}
95103

96-
handleAjaxError = (message) => {
104+
const handleAjaxError = (message) => {
97105
if (session) session.abort();
98106

99107
dispatchMessages([

src/Mollie_HyvaCompatibility/view/frontend/templates/product/view/subscription-options.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $heroicons = $viewModels->require(HeroiconsOutline::class);
2525
<button
2626
@click="setOption"
2727
type="submit"
28-
class="action primary tocart product-addtocart-button select-subscription"
28+
class="btn btn-secondary action primary tocart product-addtocart-button select-subscription"
2929
value="onetimepurchase"
3030
title="<?= __('One Time Purchase') ?>"
3131
form="product_addtocart_form"

0 commit comments

Comments
 (0)