Phoca Cart is great for B2B but need to show Original Price only

Phoca Cart - complex e-commerce extension
User avatar
dmlwebal
Phoca Professional
Phoca Professional
Posts: 238
Joined: 18 Sep 2019, 12:49

Phoca Cart is great for B2B but need to show Original Price only

Post by dmlwebal »

Hi,

Joomla 4.1.5
Phoca Cart 4
Gantry 5.5.14
Joomlead Particles and UIKIT 3 Atom


I have a demo site site set up to test various aspects of Phoca Cart 4 for B2B and so far Phoca Cart is perfect for B2B (eg. _ _ prices and customers assigned to PC Customer Groups)

Currently there are 4 Customer Groups and I have set Prices to show only to Customer Groups, this is ideal.

BUT, it would be even better to show Original Price field even when Prices are not visible.

Reason: I can use Language Overrides to rename Original Price to RRP (Recommended Retail Price) and use CSS to style it (eg. no strikethrough)

So, is there an override and a bit of PHP I can add to Phoca Cart that will allow Original Price field to display? Which file do I need to edit to allow this?

The idea is for B2B sellers to display the RRP of products (by using Original Price Field) throughout the site so that business buyers can see their buy price as compared against the Suggested Retail Price/RRP/MRP

Phoca Cart is perfect for B2B and this is a huge advantage over other Carts (including Shopify and Woocommerce, etc.) but this small change would make it even better I think.

Also I notice that Attribute prices are complex for Customer Groups, but this is not so bad as B2B stores can use individual listings for each product type.

David
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47865
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by Jan »

Hi, it depends when do you want to display it. Generally, the original price is generated in category/items and item view and displayed in layout file

components/com_phocacart/layouts/product_price.php

Code: Select all

<?php if (isset($d['priceitemsorig']['bruttoformat']) && $d['priceitemsorig']['bruttoformat']) { ?>
		<div class="ph-price-txt ph-price-original-txt"><?php echo Text::_('COM_PHOCACART_ORIGINAL_PRICE') ?></div>
		<div class="ph-price-original"><?php echo $d['priceitemsorig']['bruttoformat'] ?></div>
	<?php } ?>
Jan
If you find Phoca extensions useful, please support the project
User avatar
dmlwebal
Phoca Professional
Phoca Professional
Posts: 238
Joined: 18 Sep 2019, 12:49

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by dmlwebal »

Thanks Jan

I guess I'm looking to find the condition that governs the visibility of 'Original Price' even if Prices are hidden from Guest users. So, I wish to see Original Price always (so long as it has a value) - even if Prices are set to 'not visible' to Public
This is because I wish to show Original Price as RRP for B2B customers, and anyone in fact, but only show Customer Group Price for B2B when they are logged in.

My understanding of the above code is that if Original Price has a value then it is displayed, that is great. But setting Display Price to 'based on Customer Group' means Original Price is not visible even when there is a value. So I need to find how to override this, ie. the if statement that governs this behaviour, so that Original Price (with a value) is always visible under any condition except when Original Price is 0.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47865
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by Jan »

Hi,

in such case, the change needs to be done in view (before it goes to layout), e.g. in category view:

components/com_phocacart/views/category/tmpl/default.php

line cca 142

Code: Select all

if ($this->t['can_display_price']) {
The code for original price needs to be added before this condition

Code: Select all

$dP['priceitemsorig']= array();
			if ($v->price_original != '' && $v->price_original > 0) {
				$dP['priceitemsorig'] = $price->getPriceItems($v->price_original, $v->taxid, $v->taxrate, $v->taxcalculationtype);
			}
So such information is send to layout.

Jan
If you find Phoca extensions useful, please support the project
User avatar
dmlwebal
Phoca Professional
Phoca Professional
Posts: 238
Joined: 18 Sep 2019, 12:49

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by dmlwebal »

Fantastic!

Many thanks Jan, all tested and working perfectly. Thank you for your time, this is a big help.

David
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47865
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by Jan »

OK
If you find Phoca extensions useful, please support the project
User avatar
dmlwebal
Phoca Professional
Phoca Professional
Posts: 238
Joined: 18 Sep 2019, 12:49

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by dmlwebal »

Hi Jan

I need this function to work also for item page and items pages (for all products view and product page view)

So, I tried to add the following to [template]/html/com_phocacart/item

Code: Select all

$dP['priceitemsorig']= array();
			if ($v->price_original != '' && $v->price_original > 0) {
				$dP['priceitemsorig'] = $price->getPriceItems($v->price_original, $v->taxid, $v->taxrate, $v->taxcalculationtype);
			}
circa line 207, but value does not display.

Have I missed something?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47865
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by Jan »

Hi, the rendering is located inside the the if in item view, so this code:

Code: Select all

echo $layoutP->render($d);
needs to be added below the code you have pasted on line 207

and this code before the line:

Code: Select all

$d					= array();
		$d['s']				= $this->s;
		$d['type']          = $x->type;// PRODUCTTYPE
		$d['priceitems']	= $priceItems;
Jan
If you find Phoca extensions useful, please support the project
User avatar
dmlwebal
Phoca Professional
Phoca Professional
Posts: 238
Joined: 18 Sep 2019, 12:49

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by dmlwebal »

Hi

Thanks Jan

So, it is not working yet, but it may help for me to show what I now have from line 202 after adding the code above.

Code: Select all

// :L: PRICE
	$price 				= new PhocacartPrice;// Can be used by options


	$priceItems = array();
	$d = array();
		$d['s'] = $this->s;
		$d['type'] = $x->type;// PRODUCTTYPE
		$d['priceitems']= $priceItems;
	$dP['priceitemsorig']= array();
			if ($v->price_original != '' && $v->price_original > 0) {
				$dP['priceitemsorig'] = $price->getPriceItems($v->price_original, $v->taxid, $v->taxrate, $v->taxcalculationtype);
			}
			echo $layoutP->render($d);
	if ($this->t['can_display_price']) {

		$priceItems	= $price->getPriceItems($x->price, $x->taxid, $x->taxrate, $x->taxcalculationtype, $x->taxtitle, $x->unit_amount, $x->unit_unit, 1, 1, $x->group_price);

		// Can change price and also SKU OR EAN (Advanced Stock and Price Management)
		$price->getPriceItemsChangedByAttributes($priceItems, $this->t['attr_options'], $price, $x);

		$d					= array();
		$d['s']				= $this->s;
		$d['type']          = $x->type;// PRODUCTTYPE
		$d['priceitems']	= $priceItems;

		$d['priceitemsorig']= array();
		if ($x->price_original != '' && $x->price_original > 0) {
			$d['priceitemsorig'] = $price->getPriceItems($x->price_original, $x->taxid, $x->taxrate, $x->taxcalculationtype);
		}
		$d['class']			= 'ph-item-price-box';
		$d['product_id']	= (int)$x->id;
		$d['typeview']		= 'Item';

		// Display discount price
		// Move standard prices to new variable (product price -> product discount)
		$d['priceitemsdiscount']		= $d['priceitems'];
		$d['discount'] 					= PhocacartDiscountProduct::getProductDiscountPrice($x->id, $d['priceitemsdiscount']);

		// Display cart discount (global discount) in product views - under specific conditions only
		// Move product discount prices to new variable (product price -> product discount -> product discount cart)
		$d['priceitemsdiscountcart']	= $d['priceitemsdiscount'];
		$d['discountcart']				= PhocacartDiscountCart::getCartDiscountPriceForProduct($x->id, $x->catid, $d['priceitemsdiscountcart']);

		$d['zero_price']		= 1;// Apply zero price if possible
		echo $layoutP->render($d);
	}
This code is too advanced for my level of PHP! :shock:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47865
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart is great for B2B but need to show Original Price only

Post by Jan »

As I remember the history of this post, the original price should be displayed independent to displaying price (set before this if clause: $this->t['can_display_price'])

This means, that on line 207 should be:

Code: Select all

$d					= array();
	$d['s']				= $this->s;
	$d['type']          = $x->type;// PRODUCTTYPE
	$d['priceitems']	= [];

	$d['priceitemsorig']= array();
	if ($x->price_original != '' && $x->price_original > 0) {
		$d['priceitemsorig'] = $price->getPriceItems($x->price_original, $x->taxid, $x->taxrate, $x->taxcalculationtype);
	}
	echo $layoutP->render($d);
If you find Phoca extensions useful, please support the project
Post Reply