News:

Looking for documentation? Take a look on our wiki

Main Menu

Customize Billing Details Address Format

Started by kenryanjr, November 09, 2020, 23:42:19 PM

Previous topic - Next topic

kenryanjr

How do I change the way the Billing & Shipping addresses are displayed in the cart?  I would like them to look more like you would see in the United States. I am using version 3.8.4 over Joomla 3.9.22. I have seen a little on this topic but it was very confusing. Thank you for any help you can give me.

Like This:
FirstName LastName
Address 1
Address 2
City, State Zip
Country

jenkinhill

You can re-order them in the shopper fields list. Far right columns on that page.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

kenryanjr

I tried that and didn't see any difference in the cart page.

kenryanjr

I want to Americanize the Name and Address. I need to explode the data and out it back together.

FirstName Last Name
Address 1
Address 2
City, State Zip

GJC Web Design

on the standard template this is already being done

         foreach ($this->cart->BTaddress['fields'] as $item) {
            if(in_array($item['name'],$cartfieldNames)) continue; ?>
         <span class="values vm2<?php echo '-' . $item['name'] ?>"><?php echo $item['value'] ?></span>
         <?php if ($item['name'] != 'title' and $item['name'] != 'first_name' and $item['name'] != 'middle_name' and $item['name'] != 'zip') { ?>
            <br class="clear"/>
         <?php
            }
         } ?>

not on your template??
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

In case you have not worked it out the code GJC refers to is in /components/com_virtuemart/views/user/tmp/edit_address_userfields.php

If you already use overrides look in /templates/[your-Joomla-template]/html/com_virtuemart/users/edit_address_userfields.php
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

kenryanjr

I am using JD Servx template from JoomDev and realized that the override template for default_address.php is different than the VirtueMart default_address.php. As stated before I tried to reorder in shopper fields and I said it didn't work. Tried again and it actually did. But it comes out like this.

first_name last_name
address_1
City
State
Zip Country
phone
email address

What I would like is

first_name last_name
address_1
City, State Zip
Country
phone
email address

Can I change that with GJCs recommnedation?


<?php
/**
*
* Layout for the shopping cart and the mail
* shows the chosen adresses of the shopper
* taken from the cart in the session
*
* @package VirtueMart
* @subpackage Cart
* @author Max Milbers
*
* @link https://virtuemart.net
* @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

<div class="billto-shipto row">
<div class="col-sm-12 col-md-12 col-lg-6">

<span><span class="vmicon vm2-billto-icon"></span>
<?php echo vmText::('COM_VIRTUEMART_USER_FORM_BILLTO_LBL'); ?></span>
<?php // Output Bill To Address ?>
<div class="output-billto">
<?php
$cartfieldNames = array();
foreach( $this->userFieldsCart['fields'] as $fields){
$cartfieldNames[] = $fields['name'];
}

foreach ($this->cart->BTaddress['fields'] as $item) {
if(in_array($item['name'],$cartfieldNames)) continue;
if (!empty($item['value'])) {
if ($item['name'] === 'agreed') {
$item['value'] = ($item['value'] === 0) ? vmText::('COM_VIRTUEMART_USER_FORM_BILLTO_TOS_NO') : vmText::('COM_VIRTUEMART_USER_FORM_BILLTO_TOS_YES');
}
?>
<!-- span class="titles"><?php echo $item['title'?></span -->
<span class="values vm2<?php echo '-' $item['name'?>"><?php echo $item['value'?></span>
<?php if ($item['name'] != 'title' and $item['name'] != 'first_name' and $item['name'] != 'middle_name' and $item['name'] != 'zip') { ?>
<br class="clear"/>
<?php
}
}
?>

<div class="clear"></div>
</div>

<?php
if($this->pointAddress){
$this->pointAddress 'required invalid';
}

?>

<a class="details <?php echo $this->pointAddress ?>" href="<?php echo JRoute::('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'$this->useXHTML$this->useSSL?>" rel="nofollow">
<?php echo vmText::('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL'); ?>
</a>

<input type="hidden" name="billto" value="<?php echo $this->cart->lists['billTo']; ?>"/>
</div>

<div class="col-sm-12 col-md-12 col-lg-6">

<span><span class="vmicon vm2-shipto-icon"></span>
<?php echo vmText::('COM_VIRTUEMART_USER_FORM_SHIPTO_LBL'); ?></span>
<?php // Output Bill To Address ?>
<div class="output-shipto">
<?php
if($this->cart->user->virtuemart_user_id==0){

echo vmText::('COM_VIRTUEMART_USER_FORM_ST_SAME_AS_BT');
echo VmHtml::checkbox ('STsameAsBT'$this->cart->STsameAsBT,1,0,'id="STsameAsBTjs" data-dynamic-update=1') . '<br />';
} else if(!empty($this->cart->lists['shipTo'])){
echo $this->cart->lists['shipTo'];
}

if(empty($this->cart->STsameAsBT) and !empty($this->cart->ST) and !empty($this->cart->STaddress['fields'])){ ?>

<div id="output-shipto-display">
<?php
foreach ($this->cart->STaddress['fields'] as $item) {

if($item['name']=='shipto_address_type_name') continue;
if (!empty($item['value'])) {
?>

<!-- <span class="titles"><?php echo $item['title'?></span> -->
<span class="values vm2<?php echo '-' $item['name'?>"><?php echo $item['value'?></span>
<?php if ($item['name'] != 'title' and $item['name'] != 'shipto_first_name' and $item['name'] != 'shipto_middle_name' and $item['name'] != 'shipto_zip') { ?>
<br class="clear"/>
<?php
}
}
}
?>

</div>
<?php
}
?>

<div class="clear"></div>
</div>
<?php if (!isset($this->cart->lists['current_id'])) {
$this->cart->lists['current_id'] = 0;

?>

<a class="details" href="<?php echo JRoute::('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=ST&virtuemart_user_id[]=' $this->cart->lists['current_id'], $this->useXHTML$this->useSSL?>" rel="nofollow">
<?php echo vmText::('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL'); ?>
</a>

</div>

<div class="clear"></div>
</div>

GJC Web Design

something like

<?php if ($item['name'] != 'title' and $item['name'] != 'first_name' and $item['name'] != 'middle_name' and $item['name'] != 'state' and $item['name'] != 'city') { ?>
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

Can I add that if you want to use a rearranged layout on the order emails then this thread may help:  http://forum.virtuemart.net/index.php?topic=117954
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

pinochico

the best option is send your question to JoomDev if you have a subscription
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

kenryanjr

Quote from: GJC Web Design on November 10, 2020, 17:16:43 PM
something like

<?php if ($item['name'] != 'title' and $item['name'] != 'first_name' and $item['name'] != 'middle_name' and $item['name'] != 'state' and $item['name'] != 'city') { ?>

This worked. Sort of...And I now know why. I don't know how to fix it...But at least I have a place to start. Thank you. What I have now, using your code and changing the order of the shopper fields is this..

first_name last_name
address_1
address_2
City State
Zip
Country
phone_1
email

I would like to add a comma between city and state and would like to get the zip up one line. However if you set the zip as the same order number as city and state it goes in front of those two because the id is lower than those two. So...redoing shopper fields maybe the answer.

GJC Web Design

QuoteHowever if you set the zip as the same order number as city and state

why?

set them in sequence

for comma u need an if($item['name'] == 'city') { echo ',';}

somewhere .. you need to experiment
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kenryanjr

Even if you set them in sequence it throws in the line break and won't put them all on the same line as I would like.

GJC Web Design

then u need to adjust your code .. you've been shown the technique ... it is of course do-able with some trial and error but u can't expect to get the code written for you here
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kenryanjr

#14
Agreed, I am working on it. Not having too much luck as of yet. But still working it. No matter what I do it throws the line break in at the end of the state. And that is where I am having issues. That has to be coming from somewhere else and not on the default_address page.