-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(payments): PAYPAL-903 Product Page Banners (Cornerstone) - creat…
…e custom price event
- Loading branch information
1 parent
c169162
commit d38686e
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const bannerUtils = { | ||
dispatchProductBannerEvent: (productAttributes) => { | ||
let price = 0; | ||
|
||
if(!productAttributes.price) return; | ||
|
||
if (productAttributes.price.without_tax && !productAttributes.price.price_range) { | ||
price = productAttributes.price.without_tax.value | ||
} | ||
|
||
if (productAttributes.price.with_tax && !productAttributes.price.price_range) { | ||
price = productAttributes.price.with_tax.value | ||
} | ||
|
||
const evt = new CustomEvent('productpricechanged', { | ||
detail: { | ||
amount: price | ||
} | ||
}); | ||
|
||
window.dispatchEvent(evt); | ||
}, | ||
}; | ||
|
||
export default bannerUtils; |