top of page

Utility

Tools

Wix Custom Product Page Code

Updated: May 30

If you are having any problem setting up the CODE, let me know in the comments, I will personally set it up for you in your website. šŸ‘šŸ˜ŠšŸ˜Š


Best Regards

Marshall


import wixData from 'wix-data';
 
$w.onReady(function () {
    const collectionId = "451aef11-5714-cf0e-6485-bebb0b70b595"; // Replace with your specific collection ID
 
    wixData.query("Stores/Products")
        .hasSome("collections", [collectionId])
        .find()
        .then((results) => {
            if (results.items.length > 0) {
                $w("#repeater1").data = results.items;
            } else {
                console.log("No products found in this collection.");
            }
        })
        .catch((error) => {
            console.error("Error querying products:", error);
        });
 
    // Set up repeater item data binding
    $w("#repeater1").onItemReady(($item, itemData, index) => {
        // Assuming price is the original price and discountedPrice is the discounted price
        const originalPrice = itemData.price;
        const discountedPrice = itemData.discountedPrice || itemData.price; // Fallback to original price if no discount
 
        // Set text values
        $item("#originalPrice").text = originalPrice.toString();
        $item("#originalPriceStrikethrough").text = originalPrice.toString();
        $item("#discountedPrice").text = discountedPrice.toString();
 
        // Price display logic
        if (originalPrice !== discountedPrice) {
            // Show strikethrough and discounted price, hide original price
            $item("#originalPrice").hide();
            $item("#originalPriceStrikethrough").show();
            $item("#discountedPrice").show();
        } else {
            // Show original price, hide strikethrough and discounted price
            $item("#originalPrice").show();
            $item("#originalPriceStrikethrough").hide();
            $item("#discountedPrice").hide();
        }
    });
});

Ā 
Ā 
Ā 

Recent Posts

See All
Wix Dynamic Title Code

<style> #dynamicHeading { font-family: Arial, sans-serif; color: #F25041; display: inline-block; overflow: hidden; white-space:...

Ā 
Ā 
Ā 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page