如何使用产品属性和数量将产品添加到购物车?

时间:2022-10-25 10:01:47

I tried to search some articles on the google but they mentioned to variation products and I don't know what they are. I'm only want to add product to cart with product attribute (or multi attribute) and quantity. I tried this url <?php echo home_url('/cart/?add-to-cart='.$product->id.'&attribute_mau-sac=#425f70'); ?> for "a" element but attribute_mau-sac doesn't add to cart width product. My products are simple products. Please help me!

我试图搜索谷歌上的一些文章,但他们提到变异产品,我不知道它们是什么。我只想用产品属性(或多属性)和数量将产品添加到购物车。我试过这个url id。'&attribute_mau-sac =#425f70'); ?>对于“a”元素,但attribute_mau-sac不会添加到购物车宽度产品。我的产品是简单的产品。请帮我!

如何使用产品属性和数量将产品添加到购物车?

1 个解决方案

#1


See my writeup here on how variations work.

请参阅我的文章,了解变体的工作原理。

First off, you want to select “Variable Product” from the “Product Data” dropdown. Simple product is the default output.

首先,您需要从“产品数据”下拉列表中选择“变量产品”。简单产品是默认输出。

如何使用产品属性和数量将产品添加到购物车?

From there, you need to go to the attributes menu. This allows you to have both global attributes than be applied to a product (set in the Products > Attributes menu on the left admin sidebar if you want to set globals) or on a per-product basis. You can see I’ve added one for pant pattern. If you want to give the customer the option of selecting it and it appearing as part of their selection in their order, make sure “Used for variations” is checked.

从那里,您需要转到属性菜单。这允许您拥有全局属性而不是应用于产品(如果要设置全局变量,则在左侧管理侧栏的“产品”>“属性”菜单中设置)或基于每个产品。你可以看到我为裤子图案添加了一个。如果您想让客户选择它并将其作为其选择的一部分显示在订单中,请确保选中“用于变化”。

如何使用产品属性和数量将产品添加到购物车?

Once checked, make sure you click the “Save attributes” button. Then you can go to the Variations tab.

选中后,请确保单击“保存属性”按钮。然后,您可以转到“变体”选项卡。

如何使用产品属性和数量将产品添加到购物车?

You can see now that I’ve added variations. This is done by choosing an option (see highlighted area in red), in this case the pant pattern. I did this because the pants affect the price. If they didn’t I could have had it set to “Any Pant Type…” You just need to make sure you have at least one (even if it is "Any" across the board). You can bulk edit the fields available with the “Choose a field to bulk edit…” dropdown. You will need at least one variation to set the Price and shipping (even if it doesn’t matter what variations the customer chooses).

你现在可以看到我添加了变化。这是通过选择一个选项(见红色突出显示的区域)来完成的,在这种情况下是裤型。我这样做是因为裤子会影响价格。如果他们没有,我可以把它设置为“任何裤型......”你只需要确保你至少有一个(即使它是“任何”全面)。您可以使用“选择要批量修改的字段...”下拉列表批量修改可用字段。您将需要至少一个变体来设置价格和运费(即使客户选择的变化无关紧要)。

On the front-end, you will see that no “Add to cart” appears without selecting attributes and the variation.

在前端,您将看到没有选择属性和变化时不会出现“添加到购物车”。

如何使用产品属性和数量将产品添加到购物车?

When you make your value selection, the price and “Add to cart” buttons appear.

选择价值时,会出现价格和“添加到购物车”按钮。

如何使用产品属性和数量将产品添加到购物车?

When the attribute for pant type is changed the price adjusts accordingly as well.

当裤型的属性改变时,价格也会相应调整。

如何使用产品属性和数量将产品添加到购物车?

#1


See my writeup here on how variations work.

请参阅我的文章,了解变体的工作原理。

First off, you want to select “Variable Product” from the “Product Data” dropdown. Simple product is the default output.

首先,您需要从“产品数据”下拉列表中选择“变量产品”。简单产品是默认输出。

如何使用产品属性和数量将产品添加到购物车?

From there, you need to go to the attributes menu. This allows you to have both global attributes than be applied to a product (set in the Products > Attributes menu on the left admin sidebar if you want to set globals) or on a per-product basis. You can see I’ve added one for pant pattern. If you want to give the customer the option of selecting it and it appearing as part of their selection in their order, make sure “Used for variations” is checked.

从那里,您需要转到属性菜单。这允许您拥有全局属性而不是应用于产品(如果要设置全局变量,则在左侧管理侧栏的“产品”>“属性”菜单中设置)或基于每个产品。你可以看到我为裤子图案添加了一个。如果您想让客户选择它并将其作为其选择的一部分显示在订单中,请确保选中“用于变化”。

如何使用产品属性和数量将产品添加到购物车?

Once checked, make sure you click the “Save attributes” button. Then you can go to the Variations tab.

选中后,请确保单击“保存属性”按钮。然后,您可以转到“变体”选项卡。

如何使用产品属性和数量将产品添加到购物车?

You can see now that I’ve added variations. This is done by choosing an option (see highlighted area in red), in this case the pant pattern. I did this because the pants affect the price. If they didn’t I could have had it set to “Any Pant Type…” You just need to make sure you have at least one (even if it is "Any" across the board). You can bulk edit the fields available with the “Choose a field to bulk edit…” dropdown. You will need at least one variation to set the Price and shipping (even if it doesn’t matter what variations the customer chooses).

你现在可以看到我添加了变化。这是通过选择一个选项(见红色突出显示的区域)来完成的,在这种情况下是裤型。我这样做是因为裤子会影响价格。如果他们没有,我可以把它设置为“任何裤型......”你只需要确保你至少有一个(即使它是“任何”全面)。您可以使用“选择要批量修改的字段...”下拉列表批量修改可用字段。您将需要至少一个变体来设置价格和运费(即使客户选择的变化无关紧要)。

On the front-end, you will see that no “Add to cart” appears without selecting attributes and the variation.

在前端,您将看到没有选择属性和变化时不会出现“添加到购物车”。

如何使用产品属性和数量将产品添加到购物车?

When you make your value selection, the price and “Add to cart” buttons appear.

选择价值时,会出现价格和“添加到购物车”按钮。

如何使用产品属性和数量将产品添加到购物车?

When the attribute for pant type is changed the price adjusts accordingly as well.

当裤型的属性改变时,价格也会相应调整。

如何使用产品属性和数量将产品添加到购物车?