简体   繁体   English

WooCommerce - 添加另一个预定的销售价格

[英]WooCommerce - Add another scheduled sale price

I will try to explain what I need:我将尝试解释我需要什么:

By default woocommerce allows to handle just 1 scheduled sale price per product, I need the possibility to add another one (for simple and variable products).默认情况下,woocommerce 允许处理每个产品的 1 个预定销售价格,我需要添加另一个(对于简单和可变产品)的可能性。

In other words, for each product I need to have 3 different prices, depending on the date the purchase is made.换句话说,对于每个产品,我需要有 3 个不同的价格,具体取决于购买日期。 Also, in the product page I need to show ALWAYS the 3 prices and their relative scheduled period of time (even if it's in the past or future).此外,在产品页面中,我需要始终显示 3 个价格及其相对预定的时间段(即使是过去或未来)。 Example:例子:

Product #1产品#1

  • from 01-01-2014 to 01-31-2014 you pay € 100 (this is what I need)从 01-01-2014 到 01-31-2014,您支付 100 欧元(这就是我需要的)
  • from 02-01-2014 to 02-28-2014 you pay € 200 (scheduled woocommerce从 2014 年 2 月 1 日到 2014 年 2 月 28 日,您支付 200 欧元(预定的 woocommerce
  • sale price) from 03-01-2014 and after you pay € 300 (regular woocommerce price)销售价格)从 2014 年 3 月 1 日开始,在您支付 300 欧元后(常规 woocommerce 价格)

Product #2产品#2

  • from 01-01-2014 to 01-31-2014 you pay € 150 (this is what I need)从 01-01-2014 到 01-31-2014,您支付 150 欧元(这是我需要的)
  • from 02-01-2014 to 02-28-2014 you pay € 280 (scheduled woocommerce sale price)从 2014 年 2 月 1 日到 2014 年 2 月 28 日,您支付 280 欧元(预定的 woocommerce 销售价格)
  • from 03-01-2014 and after you pay € 330 (regular woocommerce price)从 2014 年 3 月 1 日起,支付 330 欧元后(常规 woocommerce 价格)

etc...等等...

Any suggestion on how to add this feature in a new plugin?关于如何在新插件中添加此功能的任何建议?

You can easily customized these conditions using inner code on WooCoomerce.您可以使用 WooCoomerce 上的内部代码轻松自定义这些条件。 No need to use any extra plugin for the same.无需为此使用任何额外的插件。 Following is the idea, how you can do that.. Hope this helps.以下是想法,你怎么能做到这一点..希望这会有所帮助。

Having a look at the Product abstract class in WooCommerce the following php code gets whether or not the product is on sale:查看 WooCommerce 中的 Product 抽象类,以下 php 代码可了解该产品是否在售:

return ($this->sale_price != $this->regular_price && $this->sale_price == $this->price);

Which seems to indicate that the _price has to be the same as the sale_price in order for it to be classed as on sale.这似乎表明 _price 必须与 sale_price 相同才能将其归类为销售。 So just所以就

update_post_meta($id, '_price', 'new sale price here too');

you can edit this code as per your required conditions.您可以根据所需条件编辑此代码。

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

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