Image Display - Payment and Shipping types

Phoca Cart - complex e-commerce extension
User avatar
nzrunner
Phoca Member
Phoca Member
Posts: 33
Joined: 27 Jul 2017, 15:52

Image Display - Payment and Shipping types

Post 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?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Image Display - Payment and Shipping types

Post 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
If you find Phoca extensions useful, please support the project
User avatar
nzrunner
Phoca Member
Phoca Member
Posts: 33
Joined: 27 Jul 2017, 15:52

Re: Image Display - Payment and Shipping types

Post 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. ;-)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Image Display - Payment and Shipping types

Post 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
If you find Phoca extensions useful, please support the project
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Image Display - Payment and Shipping types

Post by Jan »

Hi, implemented in version 3.0.0 RC9.2
https://www.phoca.cz/download/category/ ... -component

Jan
If you find Phoca extensions useful, please support the project
Post Reply