简体   繁体   English

以编程方式将产品添加到Virtuemart?

[英]Programmatically add product to Virtuemart?

For a customer I am building a Virtuemart 2.0.26d website. 对于客户,我正在构建一个Virtuemart 2.0.26d网站。

Because of a local law, for each unit of a product that is ordered a fee must be added. 根据当地法律,必须为订购的产品的每个单元增加费用。

So, when ordering 4 products, the fee must be charged 4 times. 因此,订购4种产品时,必须收取4次费用。 By law it is required that the total sum of this fee is visible on the invoice/order confirmation. 根据法律,这笔费用的总和必须在发票/订单确认中可见。

I looked at the price rules in Virtuemart, but they don't seem to have an option for this. 我查看了Virtuemart中的价格规则,但似乎没有这种选择。 There is a price modifier after tax, but then the fee is visibile as an negative discount. 税后有价格修改器,但该费用作为负折扣可见。 Something I don't want. 我不想要的东西。

The only solution I came up with is to make a new product for the fee and programmatically add this product for each unit. 我想出的唯一解决方案是付费制作新产品,并以编程方式为每个单元添加该产品。 Can this be done by making a Virtuemart Plugin, or must I change the core for this? 可以通过制作Virtuemart插件来完成此操作,还是必须为此更改内核?

Or are there better solutions for this problem? 还是针对此问题有更好的解决方案?

You can add extra charge by Taxes & Calculation Rules. 您可以按“税收和计算规则”添加额外费用。 create new rules and select tax per product for Type of Arithmetic Operation and select Math Operation + Or +% as per you want to add extra fee per product. 创建新规则并为算术运算类型选择每种产品的税,然后根据您想要为每种产品添加额外费用的方式选择数学运算+或+%。

您可以向每个产品添加费用金额的自定义字段,并更改付款插件的代码以将此费用添加到您的订单中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM