2015-04-21 12:17 阅读 54

想要在woocommerce / measurement calculator插件的产品页面上添加一个复选框

I want to add a checkbox to products in certain categories in my online shop, but when the checkbox is ticked it will need to add 'x' amount to the total of the product.

To complicate things further, the product is total is calculated by (area x product price) after the user has inputted their required Length and Width, the checkbox will need to use the area value and then multiply the area by 2.5 and then add that sub-total to the grand total of the product. It's an add-on to the product. If you catch my drift?

Here's a link to a sample product page. The products are carpets, so when you to tick the checkbox, the carpets will have a stain protection applied and will be charged for.

Is there any snippet of code that could help me here?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongsu3138 dongsu3138 2015-05-05 14:34

    So it was a relatively easy solution. It was just a case of turning the product into a variable product and using attributes to make a "yes or no" drop-down box, with one of the options having an increased price. This makes the price change before the area is calculated, unlike the 'product add-ons' plugin, which adds on after.

    I can't believe it took me two weeks to find the answer to this.

    点赞 评论 复制链接分享