VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: kenryanjr on November 09, 2020, 23:42:19 PM

Title: Customize Billing Details Address Format
Post by: kenryanjr on November 09, 2020, 23:42:19 PM
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
Title: Re: Customize Billing Details Address Format
Post by: jenkinhill on November 10, 2020, 09:31:58 AM
You can re-order them in the shopper fields list. Far right columns on that page.
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 10, 2020, 14:36:25 PM
I tried that and didn't see any difference in the cart page.
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 10, 2020, 14:44:11 PM
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
Title: Re: Customize Billing Details Address Format
Post by: GJC Web Design on November 10, 2020, 16:08:01 PM
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??
Title: Re: Customize Billing Details Address Format
Post by: jenkinhill on November 10, 2020, 16:39:53 PM
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
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 10, 2020, 16:59:48 PM
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>
Title: Re: Customize Billing Details Address Format
Post by: 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') { ?>
Title: Re: Customize Billing Details Address Format
Post by: jenkinhill on November 10, 2020, 18:16:49 PM
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
Title: Re: Customize Billing Details Address Format
Post by: pinochico on November 10, 2020, 18:19:39 PM
the best option is send your question to JoomDev if you have a subscription
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 10, 2020, 19:16:50 PM
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.
Title: Re: Customize Billing Details Address Format
Post by: GJC Web Design on November 10, 2020, 20:35:44 PM
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
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 10, 2020, 21:30:38 PM
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.
Title: Re: Customize Billing Details Address Format
Post by: GJC Web Design on November 10, 2020, 23:32:08 PM
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
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 11, 2020, 00:11:08 AM
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.
Title: Re: Customize Billing Details Address Format
Post by: Jörgen on November 11, 2020, 09:24:37 AM
It comes from the loop. You have to inhibit the linefeed yourself. Add some extra '--x--' or whatever in the loop and You will see where it happens.

Jörgen
Title: Re: Customize Billing Details Address Format
Post by: kenryanjr on November 11, 2020, 16:20:08 PM
Quote from: Jörgen on November 11, 2020, 09:24:37 AM
It comes from the loop. You have to inhibit the linefeed yourself. Add some extra '--x--' or whatever in the loop and You will see where it happens.

Jörgen

Thank you. I am not very good at PHP so I am trying to learn.