top of page

Dynamic Add-to-Cart Button for Custom E-commerce Stores

May 10, 2024
1 min read

Updated: Dec 30, 2024



Velo Code:


import { cart } from 'wix-stores';

export function addToCart_click(event) {
    let product = $w('#dynamicDataset').getCurrentItem();
    let idProduct = product.productReference;

    $w('#shoppingCartIcon1').addToCart(idProduct)
        .then(() => {
            console.log("Product Added");
            cart.showMiniCart();
        })
        .catch((error) => {
            console.log(error);
        });
}

Enjoy!

108 Comments


Bài viết về nút thêm vào giỏ hàng động làm tôi chú ý đến những thay đổi rất nhỏ trong giao diện mà bình thường dễ bỏ qua. Chỉ một trạng thái nút, cách hiện thông báo hay thời điểm cập nhật cũng có thể ảnh hưởng đến cảm giác sử dụng. Đọc đến đoạn này, tôi nhớ những lúc rảnh từng nghe bạn bè nói về game bài đổi thưởng và cái tên JD88 cũng từng xuất hiện trong mạch trò chuyện đó, dù tôi chưa dùng qua. Liên tưởng này khá tình cờ, nhưng nó khiến tôi thấy phần kỹ thuật phía sau các thao tác quen thuộc đáng để để ý hơn.

Like

Tôi vừa đọc bài về nút thêm vào giỏ hàng động và thấy điểm đáng chú ý nằm ở việc nút thay đổi theo lựa chọn của người xem, thay vì giữ nguyên một trạng thái. Khi nghỉ giữa giờ, đôi lúc tôi nghe người quen kể về Game bài đổi thưởng; JW88 là một cái tên từng được nhắc đến trong những câu chuyện ngoài lề đó, nhưng tôi chưa có trải nghiệm gì với lĩnh vực này. Đặt cạnh bài viết thì hai chuyện khác nhau, chỉ gặp nhau ở chỗ giao diện cần phản hồi rõ ràng với người đang nhìn vào nó. Tôi vẫn còn muốn hiểu hơn cách Wix xử lý phần này.

Like

carollee57522
3 days ago

I find exploring visual ideas through observation easier to approach when there is a familiar situation to start from. A small choice of colour or viewpoint can change the feeling of an image. That thought gives me a starting point for exploring creative visual expression in connection with Distinctivefocus. That is the part I would keep thinking about after moving on to something else. How would you describe that change to someone who has not seen the work?

Like

kevinharris0932
3 days ago

The idea of exploring visual ideas through observation gives me a reason to slow down and consider the details. A small choice of colour or viewpoint can change the feeling of an image. With Discoveratlantachineseart in mind, creative visual expression feels like a topic worth exploring one question at a time. I would rather explore one useful example carefully than pretend that the whole subject is already clear. How would you describe that change to someone who has not seen the work?

Like

I like thinking about understanding materials and practical workshop tasks through small observations rather than trying to reach a conclusion immediately. Knowing what a component needs to do can make choosing a material easier to discuss. That practical perspective helps me frame practical technical skills as a theme for Bighornsheetmetal. I would rather explore one useful example carefully than pretend that the whole subject is already clear. Which questions should come before comparing different technical options?

Like
bottom of page