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

@W-15654904Showing strikethrough price on PLP #1760

Merged
merged 45 commits into from May 16, 2024

Conversation

alexvuong
Copy link
Collaborator

@alexvuong alexvuong commented Apr 24, 2024

Description

This PR implemented strikethrough price for products on PLP if any product has a listing sale price
image

NOTE: You may notice the price may/ may not display correctly in Recommendation section/Recently View. It will be fix later in a different ticket, please ignore.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • (change1)

How to Test-Drive This PR

  • Checkout the code
  • npm ci at root
  • start retail app
  • Confirm price display for different type of products
* Standard product/Bundle: since there are no variations always show the exact list price, and a strikethrough price (if promo or price-book adjustment) and callout 
    * No swatches
    * No range of price
    * Show whatever is the LOWER sale price


* Variant products: 
    * The initially loaded product tile image should be the representedProduct
    * We will display swatches for color variants of products with that variant type
        * Customers should be able to configure (constants or config? or just override?) the variant facet used to populate the swatches because color is just one possible variant type employed by users
    * On initial load:
        * Display a price range “From X Y” inclusive of all the variants of that product
            * X is the lowest variant price (including price book sale adjustments & promotional discounts)
            * Y is that given lowest priced variant’s list price
        * When a filter is applied or a variant is selected
            * If we have a single variant show the exact price
            * If we have multiple variants show a range
        * This should be abstracted in such a way that logic should be overridable
    * We will show the callout message for the promotionId that provides the greatest possible, non-conditional discount for the shown variant
    * Product Tile should link the users to the selected variant from PLP to PDP
* Product sets: 
    * The initially loaded product tile will be the master product
    * We will NOT EVER display a swatch
    * Show From X where X is the lowest price among the set children
    * We will show the callout message for the promotionId that provides the greatest possible, non-conditional discount

  • Master product on first load
    image

  • Bundle
    image

  • Standard
    image

  • Product set
    image

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@alexvuong alexvuong requested a review from a team as a code owner April 24, 2024 00:52
@@ -16,7 +16,6 @@ import {useQuery} from '@tanstack/react-query'
import {
useAccessToken,
useCategory,
useCustomerBaskets,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused variable

import {useCurrentBasket} from '@salesforce/retail-react-app/app/hooks/use-current-basket'
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
import {useCustomerBaskets} from '@salesforce/commerce-sdk-react'
import {
mockCustomerBaskets,
mockEmptyBasket
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused variable as lint complains

useShopperOrdersMutation,
useShopperBasketsMutation
} from '@salesforce/commerce-sdk-react'
import {useShopperOrdersMutation, useShopperBasketsMutation} from '@salesforce/commerce-sdk-react'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused variables as lint complains

Copy link
Collaborator

@joeluong-sfcc joeluong-sfcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still consider merging this into a feature branch that will then later be merged into the v3/template-retail-react-app branch. It'll be easier to keep track of the product tile revamp changes as we continue our feature work

@alexvuong alexvuong changed the base branch from v3/template-retail-react-app to v3/product-tile-revamp April 25, 2024 23:52
@alexvuong alexvuong requested a review from vmarta May 13, 2024 19:37
Comment on lines 203 to 218
/**
* Find the smallest value by key from a given array
* @param arr
* @param key
*/
export const getSmallestValByProperty = (arr, key) => {
if (!arr || !arr.length) return undefined
if (!key) {
throw new Error('Please specify a key.')
}
const vals = arr
.map((item) => item[key])
.filter(Boolean)
.filter(Number)
return vals.length ? Math.min(...vals) : undefined
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be a better idea to inline this as a private function in your product utils. I don't think it's usefulness is going to be that high and we'd but have to support it forever as it's a public api

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I have moved the function into product-utils.js

Comment on lines +75 to +83
if (isASet) {
return renderCurrentPrice(true)
}

if (isMaster) {
return renderPriceSet(isRange)
}

return <Box>{renderPriceSet(false)}</Box>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this result. The code feels easier to digest.

@alexvuong alexvuong merged commit 92ffd12 into v3/product-tile-revamp May 16, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants