Jump to content

Product reduction with fixed price


Recommended Posts

Hello, I have a tough one.

 

I have a product with base price 10 and with tax including 12.3€

 

I also have a group named B2B where the customers have discounted prices without tax and a fixed price (not discounts).

B2B group shows prices without tax

Default group shows prices with tax

 

So when there is a B2B customer in product.tpl,  I want to show

Wholesale price: 5€

Suggested retail price: 12.3€

 

I managed to show the text by identifying the group, but either I enter productPrice or productPriceWithoutReduction I get the same result which is 5€.

 

Can I somehow get the base price of the product?

Thanks

post-415883-0-17494600-1459434884_thumb.jpg

Link to comment
Share on other sites

Do you use combinations (attributes)? Combinations significantly complicate this improvement.

 

Yes I do, but they don't have different price. 

 

A solution that I have thought is to override/extend Product class where to return only the base price. But I saw there that somehow it saves base price 

// keep base price
$this->base_price = $this->price;

My php and prestashop knowledge is limited, so I don't know where and how to retrieve this price.

Edited by joss54 (see edit history)
Link to comment
Share on other sites

Just two examples:

{convertPrice price=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 6, $smarty.const.NULL, false, false)}

See the getPriceWithoutReduct and getPrice methods in the Product class for more options how to get different prices.

Link to comment
Share on other sites

Just two examples:

{convertPrice price=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 6, $smarty.const.NULL, false, false)}

See the getPriceWithoutReduct and getPrice methods in the Product class for more options how to get different prices.

 

Unfortunately this isn't correct. It just displays the price with tax. 

So in the example it shows:
Wholesale price: 5€
Retail price: 6.15€ (5€+VAT)
 
I need products base price which is 10+VAT.
Link to comment
Share on other sites

OK , I have found on Product class that all   getPriceWithoutReduct, getPrice or getPublicPrice work with getPriceStatic function and send different parameters.

 

the getPriceStatic function init is

public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null,
		$only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null,
		$id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null,
		$use_customer_price = true)

I think what matters here is $use_group_reduction = false

So I have made a copy of getPublicPrice and changed all reductions to false, the result:

public function getPublicBasePrice()
{
	$specific_price_output = null;
	return Product::getPriceStatic((int)$this->id, false, null, 6, null, false, false, 1, false, null, null, null, $specific_price_output, false, false, null, false);
}

In product.tpl I request it as

{convertPrice price=$product->getPublicBasePrice()}

BUT IT DOES NOT WORK!! :(((

Again it brings the fixed price. Somehow I have to find and retrieve the product base price without the specific fixed discounted price. 

Edited by joss54 (see edit history)
Link to comment
Share on other sites

I found the solution which was to extend the Product class in override folder

class Product extends ProductCore
{
    public function getCustomBasePrice(Context $context = null)
    {
        if (!$context)
            $context = Context::getContext();
            
        return Db::getInstance()->getValue('SELECT product_shop.`price`
                    FROM `'._DB_PREFIX_.'product` p
                    '.Shop::addSqlAssociation('product', 'p').'
                    WHERE p.`id_product`='.(int)$this->id
                );
    }
}

and I retrieve it in product.tpl with

{convertPrice price=$product->getCustomBasePrice()}
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...