Promotion's List Price V4.8

similar topicsimilar topic

similar topic: https://forum.cs-cart.com/topic/14708-promotions-original-price/#entry235625

Hello, is it possible to make a discount on the list price?

/public_html/app/functions/fn.promotions.php

a new function has been added.

function fn_promotion_apply_discount_list_price($promotion_id, $bonus, &$product, $use_base = true, &$cart = null, &$cart_products = null)
{
    if (!isset($product['promotions'])) {
        $product['promotions'] = array();
    }
if (!isset($product['discount'])) {
    $product['discount'] = 0;
}

if (!isset($product['list_price'])) {
    $product['list_price'] = db_get_field("SELECT list_price FROM ?:products WHERE product_id = ?i", $product['product_id']);
}
if (!isset($product['base_price'])) {
    $product['base_price'] = $product['list_price'];
}

$product['base_price'] = $product['original_price'] = $product['price'] = $product['list_price'];
$base_price = ($use_base == true) ? $product['list_price'] + (empty($product['modifiers_price']) ? 0 : $product['modifiers_price']) : $product['list_price'];

$discount = fn_promotions_calculate_discount($bonus['discount_bonus'], $base_price, $bonus['discount_value'], $product['list_price']);
$discount = fn_format_price($discount);

$product['discount'] += $discount;
$product['price'] = $product['list_price'] - $discount;

if ($product['price'] < 0) {
    $product['discount'] += $product['price'];
    $product['price'] = 0;
}

$product['promotions'][$promotion_id]['bonuses'][] = array (
    'discount_bonus' => $bonus['discount_bonus'],
    'discount_value' => $bonus['discount_value'],
    'discount' => $product['discount']
);

if (isset($product['subtotal'])) {
    $product['subtotal'] = $product['price'] * $product['amount'];

    if (is_array($cart) && is_array($cart_products)) {
        $cart['subtotal'] = 0;
        foreach ($cart_products as $cart_product_code => $cart_product) {
            $cart['subtotal'] += $cart_product['subtotal'];
        }
    }
}

if (!empty($base_price)) {
    $product['discount_prc'] = sprintf('%d', round($product['discount'] * 100 / $base_price));
} else {
    $product['discount_prc'] = 0;
}

return true;

}

function fn_promotion_apply_catalog_rule_list_price($bonus, &$product, &$auth)
{
if ($bonus[‘bonus’] == ‘product_list_price_discount’) {
if (!isset($product[‘extra’][‘promotions’][$bonus[‘promotion_id’]]) && !isset($product[‘promotions’][$bonus[‘promotion_id’]])) {
fn_promotion_apply_discount_list_price($bonus[‘promotion_id’], $bonus, $product);
}
}

return true;

}

.

/public_html/app/schemas/promotions/schema.php

this line has been added.

$schema['bonuses']['product_list_price_discount'] = array (
    'function' => array('fn_promotion_apply_catalog_rule_list_price', '#this', '@product', '@auth'),
    'discount_bonuses' => array('to_percentage', 'by_percentage', 'to_fixed', 'by_fixed'),
    'zones' => array('catalog'),
);

.

I would like to make a percentage discount on the list price of the products.

a sample product:

List Price: 30.00$

Price: 27.00$
Discount : 10%

----

with promotion:

List Price: 30.00$

Promotion Discount : 30%

Price: 21.00$

can you help me with this?

Is there someone who can help?

Do you have friends who will make it a paid module?