创建以克为单位出售的Woocommerce产品 [英] Create a Woocommerce product sold in units of gram

查看:48
本文介绍了创建以克为单位出售的Woocommerce产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在WooCommerce中创建以克为单位出售的产品。

I would like to create a product in WooCommerce that is sold in units of gram.

客户将输入他们想要的克数(在输入字段中) ),然后即时计算价格并将其添加到购物车。

The customer would enter the number of grams they want (in an input field) on the product page, and the price would be computed on the fly and added to the cart.

我的问题是:这可能吗? ,有人可以给我一个大概的实现方式的想法吗?

我不需要逐行代码,只是希望对Woo的结构有更多了解的人可以指导我如何最好地解决问题。

I don't need line-by-line code, just hoping someone with more knowledge of the structure of Woo can guide me on how to best attack the problem.

我已经解决了部分问题:

I already have parts of it worked out:


  • 我可以确定为产品输入的价格是每
    100克的价格,因此卖家将以这种方式输入

  • I can decide that the price entered for the product is the price per 100 grams, so that is how the seller will enter the price.

然后,我可以
编写一些Javascript即时计算价格,然后
将其显示在用户输入所需金额时显示页面。没有
问题。

Then I can write a little bit of Javascript to compute the price on the fly and display it on the page as the user types the amount they want. No problem.

但是...我认为Woo中的每个分立产品都需要有自己的产品价格。例如,如果客户要某产品123克,似乎我可能必须针对该特定价格/金额动态创建一个变体,然后将其添加到购物车中。哪个(以此判断)看起来并不平凡骇客有更好的方法吗?

But... I think every discrete product in Woo needs to have its own price.. So for example, if a customer wants 123g of a product, it seems like I might have to create a variation on the fly for that specific price/amount, and then add that to the cart. Which (judging by this) looks non-trivial and a little hacky. Is there a better way to do this?

推荐答案

我发现此插件可以完全满足我的需要- https://woocommerce.com/products/measurement-price-calculator/

I found this plugin that does pretty much exactly what I need-- https://woocommerce.com/products/measurement-price-calculator/

这篇关于创建以克为单位出售的Woocommerce产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆