Order and Invoice Billing and Shipping Addresses change to City State Zip

Phoca Cart - complex e-commerce extension
User avatar
David-Spring
Phoca Member
Phoca Member
Posts: 33
Joined: 15 Dec 2020, 11:21

Order and Invoice Billing and Shipping Addresses change to City State Zip

Post by David-Spring »

I am using the latest versions of Joomla, Astroid and Phoca Cart. I have also read the Phoca Cart manual and all 50 pages of the Phoca Cart forum and I have not found anything that addresses this Zip Code placement problem.

I am a web design instructor in the US developing a college level course on how to combine Joomla CMS, Astroid template framework and Phoca Cart Shopping component to create an online store. My goal is to encourage more small business owners in the US to use Phoca Cart. There are just a few minor problems I am trying to overcome. One problem is that the default structure of Phoca Cart Order and Invoice Billing and Shipping Addresses has the Zip Code come BEFORE the City while the normal structure in the US is City, State, Zip all on one line with Zip Code at the END of the line – not at the beginning.

I have been able to get a custom field called State to appear in the Checkout Page. But I have not been able to get the data from this custom State field to appear in the Billing and Shipping Address sections of the default Order and Invoice forms. I solved this problem by using the default Region field and then using States as values for the regions. I use a language override to change the word Region into State.

I am also able to get the zip code to appear at the end of the Billing and Shipping address sections in the Checkout page by changing the order of the Zip Code field in Form Fields section. However, I have had a much harder time getting the Zip Code field to come AFTER City and State on the default Order and Invoice forms associated with each Order.

I determined that the layout for the default Order and Invoice forms is set by com_phocacart/layouts/order.php starting at Line 412 (billing address section):
$city = array();
if ($v['zip'] != '') { $city[] = $v['zip'];}
if ($v['city'] != '') { $city[] = $v['city'];}
if (!empty($city)) {$ob[] = implode("\n", $city).'<br />';}
//echo '<br />';
if (!empty($v['regiontitle'])) {$ob[] = $v['regiontitle'].'<br />';}
if (!empty($v['countrytitle'])) {$ob[] = $v['countrytitle'].'<br />';}

I used Phoca Commander to manually moved the zip code line below the region line and made the zip code line like the region line. I also deleted 2 line breaks and two dots, so the lines changed to:
$city = array();
if ($v['city'] != '') { $city[] = $v['city'];}
if (!empty($city)) {$ob[] = implode("\n", $city);}
if (!empty($v['regiontitle'])) {$ob[] = $v['regiontitle'];}
if (!empty($v['zip'])) {$ob[] = $v['zip'];}
if (!empty($v['countrytitle'])) {$ob[] = $v['countrytitle'].'<br />';}

I also made the same change at line 466 (shipping address section).

This works. Billing and Shipping addresses on the default Order and Invoice forms are now City, State and then Zip all on one line. But this solution is only temporary as I could not figure out how to convert this change into a template override. So the next Phoca Cart update will delete this fix.

My hope is that:
You would consider changing the code in com_phocacart/layouts/order.php to the revised code above so that the zip code comes at the end and City, State and Zip code are all on one line.
Alternately, that you can add an option so businesses in the US can place the Zip Code at the end of the Billing and Shipping Address.
Alternately, that you can explain how to create a template override to address this problem. I know how to do template overrides. But there was no option to do a template override for this particular php file.
Alternately, I am wondering if there is a way to get a custom form field to appear in the Billing and Shipping Address Section of the Order and Invoice forms. (I do not think there is).

If you would like to view the site, it is Create Your Own Online Store dot org. If you would like Admin access to the backend, email me and I would be happy to provide it. Thank you for your assistance in this matter.
jpeters
Phoca Professional
Phoca Professional
Posts: 225
Joined: 31 Dec 2020, 09:46

Re: Order and Invoice Billing and Shipping Addresses change to City State Zip

Post by jpeters »

create a overide .
https://www.phoca.cz/documents/116-phoc ... -overrides

in this case make a copy of com_phocacart/layouts/order.php to
templates/your_default_template/html/layouts/com_phocacart/order.php
Post Reply