Question

I have been playing around with the Default Template and trying to change some of it's features. On my product page (catalog/view/theme/mytheme/template/product/product.tpl), I want to display the price after the discount has been applied, depending on my customer group.

I know I am not using the best solution to query my user group since I have hard coded information, but here is how looks :

<?php
    $customer_group_id = $this->customer->getCustomerGroupId();

    if (is_null($customer_group_id))
    {
        // not logged in
        // show full price
        echo $price;
    }
    else
    {
        if ($customer_group_id == "1")
        {
            // customer group used with full price
            echo $price;
        }
        else
        {
            // customer group with discount
            # ?????????????????????????????
        }
    }
?>

I would like to know how to display the price with the discount allowed to the user. In my products, under the "Discount" tab, I have entered a discount for my desired customer group with the following details :

Quantity : 0
Priority : 0
Price : 5.00
Date Start : 2000-01-01
Date End : 2050-12-31

Under the "Data" tab, my price is set at "7.00".

I have tried several bits of code but none that shows the discount code. However, I do have the full price showing if my user is not logged in or logged in as a user in the other user group.

Any suggestions ?

Was it helpful?

Solution

Probably You are mixing up with a discount and a special price... Discount is meant as a sale if You buy more items, lets say that basic price is $35, but You want to give customers the discount if they buy more than 10 pieces at once, let's say $30, and 20$ if they buy more than 25 items at once, and $10 if they buy more than 100 pcs at once.

Then You would set the discount(s) like this:

Customer Group | Quantity | Priority | Price | Start | End
pick one       | 10       | 1        | 35    |       |
pick one       | 25       | 2        | 20    |       |
pick one       | 100      | 3        | 10    |       |

These discounts would then be applicable only for logged in customers that are from the desired customer group.

The value that You wish to set is the Special - and again, the special price will be immediately available to a logged in customer from the desired customer group - so no checking for the customer group is needed... For more details check the SQL query in method getProduct() (or getProducts()) within catalog/model/catalog/product.php model class - the discounts and the specials are already joined and selected regarding the customer group of logged in customer.

Just leave it as it was:

<div class="price"><?php echo $text_price; ?>
    <?php if (!$special) { ?>
    <?php echo $price; ?>
    <?php } else { ?>
    <span class="price-old"><?php echo $price; ?></span> <span class="price-new"><?php echo $special; ?></span>
    <?php } ?>
...

Should You need to change the order (special price first), change the appropriate line to

<span class="price-new"><?php echo $special; ?></span> <span class="price-old"><?php echo $price; ?></span>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top