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

#33161: Budsies | Product Price - update after promotional campaign content changed #519

Open
wants to merge 11 commits into
base: budsies-theme
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions components/atoms/a-product-price.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
</template>

<script>
import { PRODUCT_PRICE_DICTIONARY } from '@vue-storefront/core/modules/catalog';

import ACustomPrice from '../atoms/a-custom-price.vue';
import { getProductDefaultPrice } from 'src/modules/shared'

export default {
name: 'AProductPrice',
Expand All @@ -25,8 +26,11 @@ export default {
}
},
computed: {
productPriceDictionary () {
return this.$store.getters[PRODUCT_PRICE_DICTIONARY];
},
price () {
return getProductDefaultPrice(this.product, this.customOptions, false)
return this.productPriceDictionary[this.product.id];
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions components/molecules/m-product-carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@
</template>
<script>
import { SfCarousel } from '@storefront-ui/vue';
import { htmlDecode } from '@vue-storefront/core/filters';
import config from 'config';
import { currentStoreView } from '@vue-storefront/core/lib/multistore';
import { formatProductLink } from '@vue-storefront/core/modules/url/helpers';
import { productThumbnailPath } from '@vue-storefront/core/helpers';
import { prepareCategoryProduct } from 'theme/helpers';

import { PRODUCT_PRICE_DICTIONARY } from '@vue-storefront/core/modules/catalog';

import { prepareCategoryProduct } from 'theme/helpers';
import OProductCard from 'theme/components/organisms/o-product-card';

export default {
Expand All @@ -57,8 +54,16 @@ export default {
}
},
computed: {
productPriceDictionary () {
return this.$store.getters[PRODUCT_PRICE_DICTIONARY];
},
carouselProducts () {
return this.products.map(prepareCategoryProduct);
return this.products.map(
(product) => prepareCategoryProduct(
product,
this.productPriceDictionary
)
);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ import { SfButton, SfHeading } from '@storefront-ui/vue';
import { BundleOption } from 'core/modules/catalog/types/BundleOption';
import Product from '@vue-storefront/core/modules/catalog/types/Product';
import { Logger } from '@vue-storefront/core/lib/logger';
import { PRODUCT_PRICE_DICTIONARY } from '@vue-storefront/core/modules/catalog';
import * as catalogTypes from '@vue-storefront/core/modules/catalog/store/product/mutation-types';
import i18n from '@vue-storefront/i18n';
import { getProductDefaultPrice, PriceHelper, ServerError } from 'src/modules/shared';
import { PriceHelper, ServerError } from 'src/modules/shared';

import ACustomProductQuantity from 'theme/components/atoms/a-custom-product-quantity.vue';

Expand Down Expand Up @@ -93,8 +94,11 @@ export default Vue.extend({
}
},
computed: {
productPriceDictionary (): Record<string, PriceHelper.ProductPrice> {
return this.$store.getters[PRODUCT_PRICE_DICTIONARY];
},
baseProductFinalPrice (): number {
const price = getProductDefaultPrice(this.product, {}, false);
const price = this.productPriceDictionary[this.product.id];
return PriceHelper.getFinalPrice(price)
},
defaultOption (): CreativityKitFormOption | undefined {
Expand Down Expand Up @@ -128,7 +132,7 @@ export default Vue.extend({
continue;
}

const price = getProductDefaultPrice(productLink.product, {}, false);
const price = this.productPriceDictionary[productLink.product.id];
const finalPrice = PriceHelper.getFinalPrice(price);

let image = productLink.product.image;
Expand Down
21 changes: 12 additions & 9 deletions components/organisms/o-cart-items-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import { PropType } from 'vue';
import { getThumbnailForProduct } from '@vue-storefront/core/modules/cart/helpers';

import { getCartItemPrice } from 'src/modules/shared';
import { CART_ITEM_PRICE_DICTIONARY, GET_CART_ITEM_PRICE } from '@vue-storefront/core/modules/cart';
import CartItem from 'core/modules/cart/types/CartItem';
import getCartItemKey from 'src/modules/budsies/helpers/get-cart-item-key.function';
import { getCustomizationSystemCartItemThumbnail } from 'src/modules/customization-system';
import { PriceHelper } from 'src/modules/shared';

import { getCartItemOptions } from 'theme/helpers/get-cart-item-options.function';
import { OrderContentItem } from '../interfaces/order-content-item.interface';
Expand Down Expand Up @@ -48,29 +49,31 @@ export default {
}
},
computed: {
cartItemPriceDictionary (): Record<string, PriceHelper.ProductPrice> {
return this.$store.getters[CART_ITEM_PRICE_DICTIONARY];
},
tableItems (): OrderContentItem[] {
return this.cartItems.map((cartItem) => {
const price: PriceHelper.ProductPrice = cartItem.checksum
? this.cartItemPriceDictionary[cartItem.checksum]
: this.$store.getters[GET_CART_ITEM_PRICE](cartItem);
const formattedPrice = PriceHelper.formatProductPrice(price);

return {
key: this.getCartItemKey(cartItem),
thumbnail: this.getThumbnailForProduct(cartItem),
name: cartItem.name,
qty: cartItem.qty,
customizations: cartItem.customizations,
customizationState: cartItem.extension_attributes?.customization_state,
specialPrice: this.getProductSpecialPrice(cartItem),
regularPrice: this.getProductRegularPrice(cartItem),
specialPrice: formattedPrice.special,
regularPrice: formattedPrice.regular,
customOptions: getCartItemOptions(cartItem)
}
});
}
},
methods: {
getProductRegularPrice (product: CartItem): string {
return getCartItemPrice(product, {}).regular;
},
getProductSpecialPrice (product: CartItem): string {
return getCartItemPrice(product, {}).special;
},
getThumbnailForProduct (product: CartItem): string {
const customizationSystemThumbnail = getCustomizationSystemCartItemThumbnail(product, this.imageHandlerService);

Expand Down
19 changes: 10 additions & 9 deletions components/organisms/o-confirm-order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
v-model="product.qty"
:image="getThumbnailForProduct(product)"
:title="product.name | htmlDecode"
:regular-price="getProductRegularPrice(product)"
:special-price="getProductSpecialPrice(product)"
:regular-price="formatPrice(cartItemPriceDictionary[product.checksum].regular)"
:special-price="formatPrice(cartItemPriceDictionary[product.checksum].special)"
class="collected-product"
>
<template #configuration>
Expand Down Expand Up @@ -234,11 +234,12 @@ import { OrderModule, ORDER_CONFLICT_EVENT } from '@vue-storefront/core/modules/
import { ORDER_ERROR_EVENT } from '@vue-storefront/core/modules/checkout';
import { OrderReview } from '@vue-storefront/core/modules/checkout/components/OrderReview';
import { Payment } from '@vue-storefront/core/modules/checkout/components/Payment';
import { CART_ITEM_PRICE_DICTIONARY } from '@vue-storefront/core/modules/cart';
import getCartItemKey from 'src/modules/budsies/helpers/get-cart-item-key.function';
import { getCustomizationSystemCartItemThumbnail } from 'src/modules/customization-system';
import { AFFIRM_MODAL_CLOSED } from 'src/modules/payment-affirm/types/AffirmCheckoutEvents';
import { getComponentByMethodCode, supportedMethodsCodes as braintreeSupportedMethodsCodes } from 'src/modules/payment-braintree';
import { getCartItemPrice, PAYMENT_ERROR_EVENT } from 'src/modules/shared';
import { PAYMENT_ERROR_EVENT, PriceHelper } from 'src/modules/shared';
import { CaliforniaPrivacyNoticeLink } from 'src/modules/true-vault';

import { createSmoothscroll } from 'theme/helpers';
Expand Down Expand Up @@ -296,6 +297,9 @@ export default {
isGiftCardProcessing: 'giftCard/isGiftCardProcessing'
}),
...mapMobileObserver(),
cartItemPriceDictionary () {
return this.$store.getters[CART_ITEM_PRICE_DICTIONARY]
},
cartItems () {
return this.$store.getters['cart/getCartItems'];
},
Expand Down Expand Up @@ -354,6 +358,9 @@ export default {
...mapActions('ui', {
openModal: 'openModal'
}),
formatPrice (price) {
return PriceHelper.formatPrice(price);
},
getCartItemOptions,
getThumbnailForProduct (product) {
const customizationSystemThumbnail =
Expand All @@ -372,12 +379,6 @@ export default {

return getThumbnailForProduct(product);
},
getProductRegularPrice (product) {
return getCartItemPrice(product, {}).regular;
},
getProductSpecialPrice (product) {
return getCartItemPrice(product, {}).special;
},
onFailure (response) {
this.$store.dispatch('notification/spawnNotification', {
type: 'danger',
Expand Down
20 changes: 16 additions & 4 deletions components/organisms/o-cross-sells-products-selector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import { PropType, defineComponent, onBeforeMount, onServerPrefetch, toRefs } from '@vue/composition-api';
import { SfHeading } from '@storefront-ui/vue';

import { PRODUCT_PRICE_DICTIONARY } from '@vue-storefront/core/modules/catalog';
import Product from '@vue-storefront/core/modules/catalog/types/Product';
import { getProductGallery } from '@vue-storefront/core/modules/catalog/helpers';
import { getProductDefaultPrice } from 'src/modules/shared';
import { PriceHelper } from 'src/modules/shared';
import { getFinalPrice } from 'src/modules/shared/helpers/price';

import { CROSS_SELL, useRelatedProducts } from 'theme/helpers/use-related-products';
Expand All @@ -35,8 +36,11 @@ import AddonOption from '../interfaces/addon-option.interface';

import MAddonsSelector from '../molecules/m-addons-selector.vue';

function getAddonOptionFromProduct (product: Product): AddonOption {
const price = getProductDefaultPrice(product, {}, false);
function getAddonOptionFromProduct (
product: Product,
productPriceDictionary: Record<string, PriceHelper.ProductPrice>
): AddonOption {
const price = productPriceDictionary[product.id];

return {
id: product.id as number,
Expand Down Expand Up @@ -97,8 +101,16 @@ export default defineComponent({
isDisabled (): boolean {
return this.$store.getters['cart/getIsAdding'];
},
productPriceDictionary (): Record<string, PriceHelper.ProductPrice> {
return this.$store.getters[PRODUCT_PRICE_DICTIONARY];
},
productOptions (): AddonOption[] {
return this.relatedProducts.map(getAddonOptionFromProduct);
return this.relatedProducts.map(
(product) => getAddonOptionFromProduct(
product,
this.productPriceDictionary
)
);
},
selectedProducts: {
get (): number[] {
Expand Down
Loading