Prestashop:在目录价格规则中添加选项以选择库存产品或缺货

I have Prestashop 1.6.1.4 and most of the products in the store are zero stock but can be ordered.

In this case I want customers who order products with zero stock (pre-order) to receive specific % discount.

How can I add such a filter in the Catalog Price Rules?

Sorry it's not possible with Prestashop.

Regards

As per our knowledge, this is not feasible by adding a condition through catalog price rules menu, but you can tweak the code to achieve this.

In order to do that, you need to create a coupon that provides the discount as per your need and then you can check the cart status and apply the generated coupon to the current cart.

You can use the following code to check cart stock status:

$stock = false;
$check = 0;
$products = $this->context->cart->getProducts();
foreach ($products as $pro)
{
if ($pro->out_of_stock)
{
$check++;
}
}
if ($check == count($products))
{
$stock = true;
}

If the value of $stock is true at the end, then all the products in your cart are out of stock. Then you can use the following code to apply cart rule to current cart:

$cart_rule_id = CartRule::getIdByCode(COUPON_CODE);
$this->context->cart->addCartRule(cart_rule_id);