On magento 1.7 I created a promotional price rule of 20% discount for "special members" customer group.
I'd like to display both prices. I thought there would be something like
$_product->getPriceByCustomerGroup( $groupId );
Goal
(not logged in):
(member logged in):
Ok, bit of a muck around, but I think I have it.
You can grab the price for the specific group id (3 in the case below) by calling setCustomerGroupId for the product. The only caveat is that once you call the setCustomerGroupId function you cannot then set the customer group id to a different group and receive the price for that group - it sets the price once and then it won't overwrite it.
In the example below I have a product that has a normal price of $399.99, for all groups except group id 3. For group id 3, I have a Catalog price rule set for a 20% discount.
If I run the code below I get:
product A: 399.99
product B (group id 3): 319.9900
product B (group id 0): 319.9900
Note how the second time I set the customer group it doesn't change the price
$_productA = $this->getProduct();
$_productB = Mage::getModel('catalog/product')->load($_productA->getId());
$_productB->setCustomerGroupId(3);
echo 'product A: '.$_productA->getFinalPrice().'<br/>';
echo 'product B (group id 3): '.$_productB->getFinalPrice().'<br/>';
$_productB->setCustomerGroupId(0);
echo 'product B (group id 0): '.$_productB->getFinalPrice().'<br/>';
2nd time lucky :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With