我在我的网站上做了一个新页面,人们可以选择购买PC零件。
我的案例是如何创建一个按钮,用于将所有选择的产品添加到购物车,然后重定向到购物车页面。
选择列表HTML代码
<div><select id="ddrakit-processor" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih processor -</option><option value='{"product_id":9,"category_id":17,"harga":"100000000","gaming":"20","render":"10","priceperform":"20"}'>Intel i99 - Rp. 100,000,000,-</option></select></div>
<div><select id="ddrakit-motheboard" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih motherboard -</option><option value='{"product_id":11,"category_id":20,"harga":"80000","gaming":"40","render":"50","priceperform":"10"}'>ASUS ROG Z999 - Rp. 80,000,-</option></select></div>
<div><select id="ddrakit-ram" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih memory RAM -</option><option value='{"product_id":10,"category_id":19,"harga":"500000","gaming":"40","render":"10","priceperform":"20"}'>V-GEN 128GB DDR8 - Rp. 500,000,-</option></select></div>
<div><select id="ddrakit-vga" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih graphic card -</option><option value='{"product_id":8,"category_id":16,"harga":"2000000","gaming":"10","render":"20","priceperform":"10"}'>RADEON RX 999 - Rp. 2,000,000,-</option><option value='{"product_id":16,"category_id":16,"harga":"16499000","gaming":"20","render":"10","priceperform":"20"}'>MSI - GeForce GTX 1080 Ti Gaming X Trio - Rp. 16,499,000,-</option></select></div>
<div><select id="ddrakit-psu" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih power supply -</option><option value='{"product_id":17,"category_id":22,"harga":"50000","gaming":"10","render":"50","priceperform":"10"}'>Corsair RM8000 8000w - Rp. 50,000,-</option></select></div>
<div><select id="ddrakit-casing" class="ddrakit"><option value='{"gaming":"0","render":"0","priceperform":"0"}'>- Pilih Casing -</option><option value='{"product_id":12,"category_id":21,"harga":"5020000","gaming":"10","render":"10","priceperform":"10"}'>Corsair Casing Gaming - Rp. 5,020,000,-</option></select></div>
谢谢。
最佳答案
在您的自定义页面中使用此链接<a href="?add-to-cart=<?php echo $loop->post->ID; ?>" rel="nofollow" data-product-id="<?php echo $loop->post->ID; ?>" class="btn btn-primary">Add to cart</a>
关于javascript - 如何在自定义页面(而非商店/产品页面)上添加到购物车按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50043276/