OpenCart > Checkout > Address dropdowns don't show full address - opencart

The shipping and billing address dropdowns during OpenCart checkout (existing addresses, logged in user) don't show items such as company name, address line 2 and post code. In fact it appears to me that the optional/non-mandatory fields are not shown in the dropdown.
How do I fix it? Is there a setting for this?

You'll need to go to *ayment_address.tpl & shipping_address.tpl
Go to: ../public_html/catalog/view/theme/[default]/template/checkout/payment_address.tpl/shipping_address.tpl
Find & Replace:
<?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?>
With:
<?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['company']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['address_2']; ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?>, <?php echo $address['postcode']; ?>
This has worked for me in Opencart 2.0.1.1

Related

Break string up and section to the end

I am using a sed command to find /controller which is a word/action
"href="/bdgp/bdgp-record-com1-form?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?> "
which changes the result like so...
href="<?php echo $this->url("bdgp", array("action"=>"bdgp-record-com1-form"))?>?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?>
This is the sed command I am using which finds the pattern like /anything/anything/anything
sed -i 's%href=\"\/\([^/]*\)\/\([^/]*\)?\([^/]*\)%href=\"<?php echo $this->url(\"\1\", array(\"action\"=>\"\2\"))?> \"<%g' changes.txt;
What I get though is this...
href="<?php echo $this->url("bdgp", array("action"=>"bdgp-record-com1-form?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?>
How would I extract out from the result the ?type=R&year=&batchNumber=escapehtml($animal->BATCH_NUMBER);?> and put it on the end?
Thanks

Dreamweaver regular expression to search and replace

I need to search and replace on file this:
<?php echo lang_xxxx; ?>
To this:
<?php echo $lang['lang_xxxx']; ?>
How to do this? The lang_xxxx is not unique, can exists anothers like lang_yyyy, lang_zzzz, etc...
You could use the following expression:
Live Example
(lang_[^;]*?);
and replace it with:
$lang['$1'];
or:
$lang['\1'];
Results:
Input: <?php echo lang_xxxx; ?>
Output: <?php echo $lang['lang_xxxx']; ?>
Input: <?php echo lang_es; ?>
Output: <?php echo $lang['lang_es']; ?>

Globally replacing short tags from all pages

I was looking to build a sed that would globally kill short tags in my scripts as there is a LOT of legacy stuff floating around that needs to be banished. I was working of a regex but it's being greedy so am looking for a non-greedy sed that will replace all occurances of
<\?=(.*)\?> ## Pattern
<?php echo $1; ?> ## Replacement
This WILL turn <?=$foo?> into <?php echo $foo; ?> but it will also turn <?=$foo?><?=$bar?> into <?php $foo?><?=$bar; ?> as well as duplicates the line of the match.
The SED looks like sed -i -e "s/<?=\(.*\)?>/<?php echo \1; ?>/g" file
My answer would assume that
<?=$foo?><?=$bar?> ## in
<?php echo $foo; ?><?php echo $bar; ?> ## out
You can try with
sed 's/<[?]=\([^?]*\)/<?php echo \1; /g' file

vi replacing with two question mark instead of one question mark

<?php echo $form->create(); ?>
<?php echo $form->hidden('id'); ?>
<?php echo $form->input('name')); ?>
<?php echo $form->submit('Save'); ?>
<?php echo $form->end(); ?>
I want to replace "; ?" with " ?".
I used the vi command ":%s/; \?/ \?/g" to do that. I got the following output
<?php echo $form->create() ??>
<?php echo $form->hidden('id') ??>
<?php echo $form->input('name')) ??>
<?php echo $form->submit('Save') ??>
<?php echo $form->end() ??>
Actually, I need the following output.
<?php echo $form->create() ?>
<?php echo $form->hidden('id') ?>
<?php echo $form->input('name')) ?>
<?php echo $form->submit('Save') ?>
<?php echo $form->end() ?>
Can you give the explanation for this strange behavior?
The \? is the vi-regular-expression for the normal ? in other program's regular expressions.
You can look at :h regex to verify this (or more precisely :h E61).
So when using ; \? you match ; (no space) and ;<space> (one space). From these matches the greediest one (see E61 - as many as possible) will be replaced with a ? thus resulting in two question-marks (one new one and the old one) when there is a space present.
The correct expression would be: s/; ?/ ?/g
EDIT: Fixed explanation to be more precise.
:%s/; \?/ \?/g
; \? match ;<space> zero or one time, and it replaces them with ?.
So you get the original ? with another ?.

regular expression find/replace in Notepad++

I'd like to replace all of the php short tags to full blown ones.
Example source text:
<a href="<?=$baseurl?>random/<?php echo $offset+$per_page; ?>" class="arrows right" <?php echo $displayright; ?>></a>
Expected final result:
<a href="<?php echo $baseurl; ?>random/<?php echo $offset+$per_page; ?>" class="arrows right" <?php echo $displayright; ?>></a>
I got as far as this:
Find what: <?=(.*)?>
Replace with: <?php echo \1; ?>
But the result is:
<a href="<?php echo $baseurl?>random/<?php echo $offset+$per_page; ?>" class="arrows right" <?php echo $displayright; ; ?>></a>
So it doesn't really work when there are multiple php opening and closing tags on one line.
How do I fix this? Thanks!
Yes, because the * operator is greedy and will try to match everything up to the final ?. You can fix this by matching everything except the ? in the closing tag:
Find what: <?=([^?]*)?>
Replace with: <?php echo \1; ?>
Put this in the Search for field:
<\?=([^?]+)\?>
And this in the replacement field:
<?php echo \1; ?>
When you use *, Notepad++ matches as much as it can, so you need to tell it what you don't want to match so it stops without finding the whole line:
Find: <?=([^?]*)?>
Replace: <?php echo \1; ?>
Using * in your regex makes it "greedy" and you don't want that. You want the first occurrence of ?> to be matched and not the last. Also, the ? character is special in regexes so you need to escape it too:
<\?=([^?]+)\?>