Post by Johnathan » Fri Jun 25, 2010 11:44 pm

For my site, I use this modification to make the customer's default address bold in their address book:

IN:

Code: Select all

/catalog/view/theme/YOURTHEME/template/account/addresses.tpl
REPLACE:

Code: Select all

<td><?php echo $result['address']; ?></td>
WITH:

Code: Select all

<td>
<?php if ($this->customer->getAddressId() == $result['address_id']) { ?>
  <span style="font-weight: bold"><?php echo $result['address']; ?></span>
<?php } else { ?>
  <?php echo $result['address']; ?>
<?php } ?>
</td>
I propose this is added to the core, so that customer's can tell which address is their default. I realize using "$this->customer->getAddressId()" in the template isn't best form, but Q or Daniel can probably figure out where to put it. Also, the language file should be changed:

IN:

Code: Select all

/catalog/language/english/account/address.php
REPLACE:

Code: Select all

Address Book Entries
WITH:

Code: Select all

Address Book Entries (default in bold)

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Moel » Sat Feb 16, 2019 5:56 am

Hopefully you are still active in this topic.

How to implement this in opencart 3.0.2.0 ?

Newbie

Posts

Joined
Sat Feb 16, 2019 5:48 am

Post by Johnathan » Sat Feb 16, 2019 11:44 pm

In OpenCart 3.0 versions:

Code: Select all

IN:
/catalog/controller/account/address.php

AFTER:
$results = $this->model_account_address->getAddresses();

ADD:
$data['default_address'] = $this->customer->getAddressId();

Code: Select all

IN:
/catalog/view/theme/YOURTHEME/template/account/address_list.twig

REPLACE:
<td class="text-left">{{ result.address }}</td>

WITH:
<td class="text-left">
{% if result.address_id == default_address %}<b>{% endif %}
{{ result.address }}
{% if result.address_id == default_address %}</b>{% endif %}
</td>

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by ddpneu » Wed May 13, 2020 2:58 pm

Hello,
could you please help me with OC 2.3.0.2 on Journal3?
The code in Journal3 for this page seems to be same as default Opencart template but it doesn´t work.

I tryed this:

Code: Select all

<file name="catalog/controller/account/address.php">
        <operation> 
			<search  position="after"><![CDATA[$results = $this->model_account_address->getAddresses();]]></search>
			<add><![CDATA[$data['default_address'] = $this->customer->getAddressId();]]></add>
	</operation>
</file>
and

Code: Select all

<file name="catalog/view/theme/journal3/template/account/address_list.tpl">
	<operation> 
			<search position="replace"><![CDATA[<td class="text-left"><?php echo $result['address']; ?></td>]]></search>
			<add><![CDATA[
			<td class="text-left"><?php if($result['address_id'] == 'default_address'){ ?><strong><?php } ?><?php echo $result['address']; ?><?php if($result['address_id'] == 'default_address'){ ?></strong><?php } ?></td>
              ]]></add>
	</operation>
</file>
Thank you

New member

Posts

Joined
Sat Sep 14, 2013 4:54 am

Post by Johnathan » Wed May 13, 2020 11:12 pm

Sorry, I can't help with Journal-specific issues. For debugging it yourself, I'd double-check that the line you're hooking into for the .tpl file exists. If it does, then you code looks fine, so you should try refreshing all your caches. Beyond that, it's probably something weird Journal is doing, so you'd need to find a Journal expert or contact their support (if they'd help with something like this).

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 19 guests