Page 1 of 1

Image Display - Payment and Shipping types

Posted: 10 Aug 2017, 01:11
by nzrunner
I noticed that the image you can save with each Payment and Shipping type is not displayed during checkout. I updated a few files to make this happen.

I made two changes to the library "administrator/components/com_phocacart/libraries/phocacart/cart/cart.php": -

For Payments, update the addPaymentCosts function, around line # 691, adding the following line:-

Code: Select all

$this->payment['costs']['image'] 	= $pI->image;
For Shipping, update the addShippingCosts function, around line # 657, adding the following line:-

Code: Select all

$this->shipping['costs']['image'] 	= $sI->image;
For the front-end view, I made changes to two files

For Payments, I edited the "components/com_phocacart/views/checkout/tmpl/default_payment.php" file: -

View mode - around line # 35: -

Code: Select all

echo '<div class="col-sm-8 col-md-8 "><img src="'. $this->t['paymentmethod']['image'] .'" style="width: 90px; padding-right: 20px; align: left;"></img>'.$this->t['paymentmethod']['title'];
Edit mode - around line # 95: -

Code: Select all

echo '<label><input type="radio" name="phpaymentopt" id="phpaymentopt'.$v->id.'" value="'.$v->id.'" '.$checked;
echo '><img src="'.$v->image.'" style="width: 90px; padding-right: 20px; align: left;"></img>'.$v->title.'</label>';
(Note: Split into two lines for easier reading)

For Shipping, I edited the "components/com_phocacart/views/checkout/tmpl/default_shipping.php" file: -

View mode - around line # 72: -

Code: Select all

echo '<div class="col-sm-8 col-md-8 "><img src="'. $this->t['shippingmethod']['image'] .'" style="width: 90px; padding-right: 20px; align: left;"></img>'.$this->t['shippingmethod']['title'];
Edit mode - around line # 132: -

Code: Select all

echo '<label><input type="radio" name="phshippingopt" id="phshippingopt'.$v->id.'" value="'.$v->id.'" '.$checked;
echo '><img src="'.$v->image.'" style="width: 90px; padding-right: 20px; align: left;"></img>'.$v->title.'</label>';
(Note: Split into two lines for easier reading)

Something for the next release?

Re: Image Display - Payment and Shipping types

Posted: 11 Aug 2017, 23:02
by Jan
Hi, great, thank you very much for the code, it was planned for next version, I just made only the backend features until now. Now, thanks your instructions, it will be faster to implement it.

Thank you, Jan

Re: Image Display - Payment and Shipping types

Posted: 12 Aug 2017, 00:35
by nzrunner
No problems!

I noticed my line #'s are a little bit out but I am sure you can figure it out.

I was going to include a component option to display/hide the image, and possibly another to set the width instead of using inline CSS, but decided to keep it simple. ;-)

Re: Image Display - Payment and Shipping types

Posted: 12 Aug 2017, 15:29
by Jan
Hi, yes, one has to save parameter count (so the system will be not overloaded). If possible the CSS is the best way.

And instead of parameter to display/hide image, it is better to check if the image was set or not - if set - display it, if not (empty image field) - don't display it. The worst for the extension is, it has a lot of parameters and nobody understand what to exactly set.

And yes, no problem with the line numbers.

Thank you, Jan

Re: Image Display - Payment and Shipping types

Posted: 06 Sep 2017, 16:33
by Jan
Hi, implemented in version 3.0.0 RC9.2
https://www.phoca.cz/download/category/ ... -component

Jan