Skip to content

Commit 2597cb3

Browse files
authored
Merge pull request #103 from BlueFinchCommerce/feature/above-payments-extension
Feature/above payments extension
2 parents c225b92 + 2b59b16 commit 2597cb3

8 files changed

Lines changed: 148 additions & 101 deletions

File tree

view/frontend/web/js/checkout/dist/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/frontend/web/js/checkout/dist/main.min.js

Lines changed: 91 additions & 91 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

view/frontend/web/js/checkout/src/components/Steps/GlobalComponents/OrderSummary/CouponDiscount/CouponDiscount.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ export default {
129129
if (!this.locale) {
130130
await this.getInitialConfig();
131131
}
132-
this.applyButtonText = window.bluefinchCheckout?.[this.applyButtonTextId] || this.$t('orderSummary.applyBtn');
133-
this.removeButtonText = window.bluefinchCheckout?.[this.removeButtonTextId] || this.$t('orderSummary.removeBtn');
132+
const translate = typeof this.$t === 'function' ? this.$t.bind(this) : (key) => key;
133+
this.applyButtonText = window.bluefinchCheckout?.[this.applyButtonTextId] || translate('orderSummary.applyBtn');
134+
this.removeButtonText = window.bluefinchCheckout?.[this.removeButtonTextId] || translate('orderSummary.removeBtn');
134135
this.couponDiscountText = window.bluefinchCheckout?.[this.couponDiscountTextId]
135-
|| this.$t('orderSummary.couponDiscountTitle');
136+
|| translate('orderSummary.couponDiscountTitle');
136137
this.couponDiscountPlaceholderText = window.bluefinchCheckout?.[this.couponDiscountPlaceholderTextId]
137-
|| this.$t('orderSummary.couponDiscount.placeholder');
138+
|| translate('orderSummary.couponDiscount.placeholder');
138139
},
139140
computed: {
140141
...mapState(useCartStore, ['cart', 'discountErrorMessage']),

view/frontend/web/js/checkout/src/components/Steps/GlobalComponents/OrderSummary/GiftCardDiscount/GiftCardDiscount.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ export default {
129129
if (!this.locale) {
130130
await this.getInitialConfig();
131131
}
132-
this.applyButtonText = window.bluefinchCheckout?.[this.applyButtonTextId] || this.$t('orderSummary.applyBtn');
133-
this.removeButtonText = window.bluefinchCheckout?.[this.removeButtonTextId] || this.$t('orderSummary.removeBtn');
134-
this.giftCardText = window.bluefinchCheckout?.[this.giftCardTextId] || this.$t('orderSummary.giftDiscountTitle');
132+
const translate = typeof this.$t === 'function' ? this.$t.bind(this) : (key) => key;
133+
this.applyButtonText = window.bluefinchCheckout?.[this.applyButtonTextId] || translate('orderSummary.applyBtn');
134+
this.removeButtonText = window.bluefinchCheckout?.[this.removeButtonTextId] || translate('orderSummary.removeBtn');
135+
this.giftCardText = window.bluefinchCheckout?.[this.giftCardTextId] || translate('orderSummary.giftDiscountTitle');
135136
this.giftCardPlaceholderText = window.bluefinchCheckout?.[this.giftCardPlaceholderTextId]
136-
|| this.$t('orderSummary.giftCardDiscount.placeholder');
137+
|| translate('orderSummary.giftCardDiscount.placeholder');
137138
},
138139
computed: {
139140
...mapState(useCartStore, ['cart', 'giftCardErrorMessage']),

view/frontend/web/js/checkout/src/components/Steps/PaymentPage/PaymentPage.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<SavedShippingMethod v-if="!cart.is_virtual" />
1616
<Rewards v-if="rewardsEnabled" />
1717
<StoreCredit />
18+
19+
<component
20+
:is="abovePaymentMethod"
21+
v-for="abovePaymentMethod in abovePaymentMethods"
22+
:key="abovePaymentMethod"
23+
/>
24+
1825
<div class="payment-page">
1926
<div class="payment-form">
2027
<ProgressBar />
@@ -143,6 +150,7 @@ import additionalVaultedMethods from '@/extensions/additionalVaultedMethods';
143150
import paymentMethods from '@/extensions/paymentMethods';
144151
import paymentMethodsPrimary from '@/extensions/paymentMethodsPrimary';
145152
import ageCheckerExtensions from '@/extensions/ageCheckerExtensions';
153+
import abovePaymentMethods from '@/extensions/abovePaymentMethods';
146154
147155
export default {
148156
name: 'PaymentPage',
@@ -163,13 +171,15 @@ export default {
163171
...paymentMethods(),
164172
...paymentMethodsPrimary(),
165173
...ageCheckerExtensions(),
174+
...abovePaymentMethods(),
166175
},
167176
data() {
168177
return {
169178
additionalPaymentMethods: [],
170179
additionalVaultedMethods: [],
171180
additionalPaymentMethodsPrimary: [],
172181
ageCheckerExtensions: [],
182+
abovePaymentMethods: [],
173183
storedStepText: '',
174184
paymentKey: 0,
175185
};
@@ -222,6 +232,7 @@ export default {
222232
this.additionalPaymentMethodsPrimary = Object.keys(paymentMethodsPrimary());
223233
this.additionalVaultedMethods = Object.keys(additionalVaultedMethods());
224234
this.ageCheckerExtensions = Object.keys(ageCheckerExtensions());
235+
this.abovePaymentMethods = Object.keys(abovePaymentMethods());
225236
226237
this.trackStep({
227238
step: 3,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineAsyncComponent } from 'vue';
2+
3+
export default () => {
4+
const abovePaymentMethods = {};
5+
// Look at window.bluefinchCheckout.abovePaymentMethods object to trigger the loading of all extra details.
6+
if (window.bluefinchCheckout?.abovePaymentMethods) {
7+
Object.keys(window.bluefinchCheckout.abovePaymentMethods).forEach((detailField) => {
8+
abovePaymentMethods[detailField] = defineAsyncComponent(() => (
9+
import(
10+
/* @vite-ignore */
11+
window.bluefinchCheckout.abovePaymentMethods[detailField]
12+
)));
13+
});
14+
}
15+
16+
return abovePaymentMethods;
17+
};

view/frontend/web/js/checkout/src/helpers/cart/getCartPrices.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ export default () => {
22
const mageCache = JSON.parse(localStorage.getItem('mage-cache-storage'));
33

44
if (!mageCache.cart) {
5-
return [];
5+
return {
6+
subtotalAmount: 0,
7+
grandTotalAmount: 0,
8+
grand_total: {
9+
value: 0,
10+
currency: undefined,
11+
},
12+
subtotal_including_tax: {
13+
value: 0,
14+
currency: undefined,
15+
},
16+
subtotal_excluding_tax: {
17+
value: 0,
18+
currency: undefined,
19+
},
20+
discounts: [],
21+
};
622
}
723

824
const { subtotalAmount, currencyCode } = mageCache.cart;

view/frontend/web/js/checkout/src/styles/global/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@
379379
--input__placeholder-font-color: var(--color__primary-grey1);
380380
--input__placeholder-font-weight: var(--font-weight__medium);
381381
--input__border-left-radius: var(--input__border-radius) 0 0 var(--input__border-radius);
382+
--input__border-right-radius: 0 var(--input__border-radius) var(--input__border-radius) 0;
382383
--input__inline-label-display: flex;
383384

384385
//

0 commit comments

Comments
 (0)