简体   繁体   English

如何在自定义页面(不是商店/产品页面)上添加到购物车按钮 Woocommerce

[英]How to make add to cart button on custom page (not shop/product page) Woocommerce

i made new page on my site that people choose PC part to buy..我在我的网站上创建了一个新页面,人们选择购买 PC 部件。

My case is how to create a button for add all product choosen to cart then redirect to the cart pages.我的情况是如何创建一个按钮,将所有选择的产品添加到购物车,然后重定向到购物车页面。

在此处输入图片说明

Select list HTML Code选择列表 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>

Thank you.谢谢你。

在您的自定义页面中使用此链接

<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>

Are you saying a form?你说的是表格? I'd use a backend server to handle the form and do the redirect to the checkout page and whatnot.我会使用后端服务器来处理表单并重定向到结帐页面等等。 Submitting form is what you should use and it's straightforward to implement.提交表单是您应该使用的,并且实施起来很简单。

you may paste this where you want to show add to cart button您可以将此粘贴到要显示添加到购物车按钮的位置

<?php
global $product;
$pid = $product->get_id();
?>
<a href="<?php echo do_shortcode( '[add_to_cart_url id=' . $pid . ']' ) ?>" class="your-classes-here">Add to cart</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WooCommerce商店页面:添加到购物车按钮上的数量输入 - WooCommerce Shop page: Quantity input on add to cart button 在非商店页面上将产品添加到购物车 - Add product to cart on a non shop page 添加到购物车按钮在 Woocommerce 的单个产品页面上不起作用 - Add to cart button not working on single product page in Woocommerce 在 WooCommerce 商店页面上添加数量字段并添加到购物车按钮 - Adding quantity fields and add to cart buton on WooCommerce Shop page woocommerce 登陆页面:如何添加添加到购物车按钮 - woocommerce landing page: how to add an add to cart button WooCommerce:如何在常规页面上使用“添加到购物车”按钮? - WooCommerce: How do I use an Add to Cart button on a normal page? 基于产品类型的 WooCommerce 的“添加到购物车”按钮旁边的自定义按钮 - Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type 将轮播滑块添加到 woocommerce 商店页面(不是单个产品页面) - Adding carousel slider to woocommerce shop page (not single product page) 刷新 WooCommerce 产品页面添加到购物车 - Refresh WooCommerce product page on added to cart Magento:CMS页上的“添加到购物车”按钮正在工作……如何使“自定义数量”系统起作用? - Magento: I have a working ‘add to cart’ button on a CMS page…How can I make a ‘custom quantity’ system work?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM