All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello, I’m trying to show random numbers for how many people have bought and seen the product in the last 24 hours. It currently works and shows like this:
But there is one problem, it disappears and when you switch variant and I don’t know how to fix this. I’m using dawn theme with the following code in main-products.liquid
code: https://codeshare.io/zl3m6N
webshop URL: https://trendblend.eu/products/controllable-led-curtain
Hi @TrendBlend,
Because when you change variant productInfo will be rerendered and your custom is in product info will be dissapeared
Try call your custom code again at the end of function "renderProductInfo" . It's in global.js file
If it helps you, please like and mark it as the solution.
Best Regards
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
I hope these instructions will help you.
Have a nice day sir!
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
Hello @BSSCommerce-B2B, thanks for the respond but the code that you editted in the codeshare still does not work when changing variant. I have this code for many products so it is a big part of code. Adding this under renderProductInfo would be adding like 1000 lines of code there, would you recommend that? Or is there maybe another way?
If your code it's too big. Try add an event when you change your variant to call your fuction again.
document.querySelectorAll(".product-form__input select").forEach(selectElement => {
selectElement.addEventListener("change", function() {
setTimeout(()=>{
// Your function here
},2000)
});
});
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now