Jump to content

Recommended Posts

Hi

 

I'm fairly new to Prestashop and am a developer. I have setup customer groups with a discount for each group. For example:

 

Group 1 - 35% discount

 

Group 2 - 40% discount

 

Group 3 - 45% discount

 

My question is fairly simple. When I log in as a customer in one of these groups, I would expect to see the non-discounted price as well as the discounted price shown on the product page, but only the reduced price is shown. Does anyone have any idea of how to achieve this? I have looked at various answers but the solutions either do not work, or are not applicable.

 

Any help would be much appreciated.

 

Thanks

David

Link to comment
Share on other sites

Not sure if there is already a module ready to display the group prices.

Seems the price displayed is dependent on the "default customer group" chosen.

 

I have also tried grouping customer into

 

1. Group 1- Distributors - 30% discount

2. Group 2- Retailers - 15% discount

3. Group 3 - no discount

 

if checked the box next to both customer groups e.g. Group 1 and Group 3 but only the one you chose on the default drop down box is displayed ( after any current specific prices rule in the product page tab is taken into account).

 

It would be great if all product price information can be displayed to the customer account according to their groups in a glance as well just like the stats dashboard. In other word, for employees/admins they can see these info in the back office easily and for customers ( e.g. distributors and retailers) they can see those in front office ( through account information) somewhere that specific products are with all relevant pricing/discount for them. These prices are also displayed together on their front office when they logged in according to their customer group e.g. distributor or retailer.

Link to comment
Share on other sites

This should be a fairly simple issue to resolve.

 

Currently if you put an individual product on sale, on the product page you see the original price with a line through it and also the sale price. All I'm looking to do is the same for group prices.

 

When the user is logged in, they will see the original price with a line through and their group price. Should be as simple as that.

 

As I'm new to Prestashop, I'm not sure if this the default behaviour, or I have to set a configuration option in the Backoffice to turn this on in the frontend.

 

Otherwise I'm thinking I will have to create an override to display this original price.

Link to comment
Share on other sites

If you use the discount proposed in the group configuration, the prices are changed, for the given group, without stroked price information, nor recution information.

 

If you want these information, dont' set discount in the group configuration and for each product, go into the prices tab, then add a reduction for the given group.

You will then have the price, the original stroked price and the recduction percent.

You have to do this with all products.

 

Note that the group discount is cumualtive with the reduction you set in the prices tab of a product

Link to comment
Share on other sites

Thanks Olea.

 

Unfortunately this solution is not very practical, as this means that if you had three groups (three reduction percentages), and 100 products, you would have to define three reductions for each product to get the desired effect of a stroked price.

 

There must be another solution to this, as this must be a fairly common request.

 

My thoughts are that I will create an override for the Product class to return the correct price and apply stylng myself.

 

Thank you again for your answer.

Link to comment
Share on other sites

If you use the discount proposed in the group configuration, the prices are changed, for the given group, without stroked price information, nor recution information.

 

If you want these information, dont' set discount in the group configuration and for each product, go into the prices tab, then add a reduction for the given group.

 

You will then have the price, the original stroked price and the recduction percent.

You have to do this with all products.

 

Note that the group discount is cumualtive with the reduction you set in the prices tab of a product

 

the trouble with doing that is we have to go to each product individually to effect the price reduction for the group through the price tab. Would be convenient that we have an option to set for all products a reduced price for the specific groups and they can automatically see the prices on their front office display according to their groups.

Link to comment
Share on other sites

  • 2 weeks later...

SOLVED.

 

To resolve this issue, as there did not seem to be any easy way via the backoffice to do this, I created

 

- an override for the Product class

 

- cloned the relevant functions and renamed them to something else

 

- modified my template to call in these new functions and display the price depending on whether a user is logged in or not.

Link to comment
Share on other sites

SOLVED.

 

To resolve this issue, as there did not seem to be any easy way via the backoffice to do this, I created

 

- an override for the Product class

 

- cloned the relevant functions and renamed them to something else

 

- modified my template to call in these new functions and display the price depending on whether a user is logged in or not.

 

prestatent, would it be possible to share how this is solved or how it looks like on your site

Link to comment
Share on other sites

Halennoor

 

Unfortunately I have not uploaded this to my server yet, but attached code as follows:

 

- priceFullCalculation function in /overrides/classes/Product.php - returns full price with tax.

 

- within your theme product.tpl file you will have some code similar to:

 

 {if $priceDisplay >= 0 && $priceDisplay <= 2}
				    {if $cookie->isLogged(true)}
					    <p class="srp">SRP:
	  <span id="old_price_display" class="srp">{convertPrice price=$product->getFullPrice(true, $smarty.const.NULL,2)}</span></p>
					    <p class="vip">VIP Price:
	   <span id="our_price_display" class="vip">{convertPrice price=$product->getPrice(true, $smarty.const.NULL,2)}</span></p>
				    {else}
	  <p class="srp">SRP:<span id="our_price_display" class="srp">{convertPrice price=$product->getPrice(true, $smarty.const.NULL,2)}</span></p>
				    {/if}
 {/if}

 

The function $product->getFullPrice returns the price from the override class in Product.php. You can then style this however you like, eg, to put a line through the price. The SRP is the full price if not logged in. The VIP price is the logged in price for the customer group.

 

Hope this helps.

Product.php

  • Like 2
Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...
  • 2 months later...
  • 6 months later...
  • 2 weeks later...
  • 3 weeks later...
  • 6 months later...
  • 7 months later...

Hey prestatent,

 

Can you explain why does that method invokes another static method? The logic couldn't just be there?

 

Thanks

 

EDIT: Also i have the following error:

 

 

 

Fatal error: Call to a member function getPrice() on a non-object in C:\xampp\apps\prestashop\htdocs\tools\smarty\sysplugins\smarty_internal_templatebase.php(157) : eval()'d code on line 186

 

 

Halennoor

Unfortunately I have not uploaded this to my server yet, but attached code as follows:

- priceFullCalculation function in /overrides/classes/Product.php - returns full price with tax.

- within your theme product.tpl file you will have some code similar to:
 

	 {if $priceDisplay >= 0 && $priceDisplay <= 2}
					    {if $cookie->isLogged(true)}
						    <p class="srp">SRP:
		  <span id="old_price_display" class="srp">{convertPrice price=$product->getFullPrice(true, $smarty.const.NULL,2)}</span></p>
						    <p class="vip">VIP Price:
		   <span id="our_price_display" class="vip">{convertPrice price=$product->getPrice(true, $smarty.const.NULL,2)}</span></p>
					    {else}
		  <p class="srp">SRP:<span id="our_price_display" class="srp">{convertPrice price=$product->getPrice(true, $smarty.const.NULL,2)}</span></p>
					    {/if}
	 {/if}
The function $product->getFullPrice returns the price from the override class in Product.php. You can then style this however you like, eg, to put a line through the price. The SRP is the full price if not logged in. The VIP price is the logged in price for the customer group.

Hope this helps.

 

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

  • 2 years later...

I did in this way:

 

Assign a customer to a group which I want to display the price. (customer id=4)

 

 

Add the folowing to      / classes / Product.php

 

 

public function getPriceGroup($id_product, $tax = true, $id_product_attribute = null, $decimals = 6, $divisor = null,
        $only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = 4, $id_cart = null,
        $id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null,
        $use_customer_price = true)
    {
        return Product::getPriceStatic((int)$this->id, $tax, $id_product_attribute, $decimals, $divisor, $only_reduc, $usereduc, $quantity,
$force_associated_tax, $id_customer, $id_cart, $id_address, $specific_price_output, $with_ecotax, $use_group_reduction, $context, $use_customer_price );
    }
 
 
And after add in the file / yourtheme / product.tpl
 
 
Price group:  {convertPrice price=$product->getPriceGroup()}

 

It took some time to learn the structure, but at the end it work. 

Hope that it will work also for you.

 

Best regards

      

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...