WebsiteBaker Support (2.8.x) > Bakery Shop

Bakery Second Address line field

<< < (3/3)

jacobi22:

--- Quote from: svsanchez on December 03, 2013, 12:28:14 AM ---
2) Then in form.htm I changed the ship textfield blocks so it now looks like this:


--- Code: ---<!-- BEGIN ship_textfields_block
<tr id="{TR_ID}">
<td class ="mod_bakery_form_label_f">{LABEL}</td>
<td><textarea type="text" class="{CSS_ERROR_CLASS}mod_bakery_form_input_f p{NAME}" name="{NAME}" value="" maxlength="{MAXLENGHT}">{VALUE}</textarea></td>
</tr>
END cust_textfields_block -->

--- End code ---
I just tried repeating what you told me for the shipping address but it wasn't as easy as I hoped, what did I do wrong?

--- End quote ---

thats wrong!!!
a comment in HTML starts with <!--, the end is  -->, i'm missing the end in your first line and the start in your last line, so the whole code is a comment in this moment
It's also important, that you not change the comment text - there are the limiter for the display - it doesnt work, if you have the text BEGIN ship_textfields_blo ck at the start and END cust_textfields_block at the end from the same block
please check your code about this or copy the code from here

Step 1
here the correct code with textareas for the shipping fields
(File: modules/bakery/templates/form/form.htm // line 81 - 86

--- Code: ---<!-- BEGIN ship_textfields_block -->
<tr id="{TR_ID}">
        <td class ="mod_bakery_form_label_f">{LABEL}</td>
        <td><textarea type="text" class="{CSS_ERROR_CLASS}mod_bakery_form_input_f p{NAME}" name="{NAME}" value="" maxlength="{MAXLENGHT}">{VALUE}</textarea></td>
</tr>
<!-- END ship_textfields_block -->
--- End code ---

Step 2 - change the CSS - is correct in your code

Step 3
change the maxlenght from 50 to 500 in view_form.php in the lines between 280 and 302 (4x)
OLD : "ship_street" => "50"
NEW  "ship_street" => "500"

Step 4
go to view_summary.php // Line 239 to this code

--- Code: ---// Join customer first and last name
        $ship_name = $ship_first_name." ".$ship_last_name;
--- End code ---

and change it to

--- Code: ---// Join customer first and last name
        $ship_name = $ship_first_name." ".$ship_last_name;
        $ship_street = nl2br($ship_street);
--- End code ---

thats all (for me). If you have some errors, please post the messages or discribe the error
i dont test the mail messages, but i think, everything is okay

one Question... (here in germany we use an other adress system)

you write, you need a street field for Entrys like this
BOX 695 [ENTER]
1869 NW 97th Ave

i think
Box 695 is a post box
1869 NW is the postal or zip-code and the City
97th Ave is the Street
correct?
what are you doing with the fields for the zip-Code and the city?




svsanchez:
Hello Jacobi!

Your solution worked great! There's only 2 minor things that I would like to fix with it:

1) When I hit the [enter] key in the address field, the email that is sent to the shop owner shows a <br />. I can tell the customer to live with it but if it's something easily fixable it would be great to remove it :)

2) Some addresses in Guatemala use the quotation marks and comma, for example we have something like 1st Street "A", 1st Street "B" when they are intermediate streets. Right now when I include a quotation mark in the address Bakery won't accept it so there's another special char that I have to add to the regexp but don't know how to represent the quotation marks and the comma (,) characters!

Regarding your questio, the example address I sent you was just to try to explain what I was trying to achieve. But in Guatemala we use something like this:

20 Calle 16-03
Colonia Granai III
Zona 11
Guatemala, Guatemala

The first line tells you the address is located in the 20th street between the 16th and 17th streets, 3 meters from the corner of the 16th avenue. Blocks here are 100 meters wide, so having an address like 20 calle 16-50 would tell you the house is located in the 20th street, between the 16th and 17th avenues, right in the middle (50 meters from the corner of the 16th).

The second line is not always used, but when the address is inside a condominum or an appartment building, you put there the name of the condominum or the building name (like for example World Trade Center was the name of the building)

The third line is like the zip code, but here we use something called Zones which have 2 digits. Each zone also has a postal code equivalent but almost nobody uses it, only the Zone.

And finally you have the City name.

So I am using both the zip and city fields but changed the zip field to allow only 2 digits (you also helped me on this one  :-) )

svsanchez:
Could someone please tell me how to tell Bakery to accept the quotes and comma characters in the address field? I have searched and googled this but haven't been able to get it to work.

jacobi22:
for the moment i use this regex in the preg_match for the field "street", it means

\s"\,\$\&\A-Za-z0-9'.$add_chars.' áéíóúñÑ+-]{1,500}
allowed:
- whitespaces (Space, tab, or newline)
- "
- ,
- &
- Chars from A-Z and a-z and 0-9
- $addchars (the special chars from the EN.php)
- your special chars áéíóúñÑ
- + and -
if you need more chars, try it at the begin from the regex nearly s\"\, use the char and a \


--- Code: ---if (strpos($field, 'street') !== false) {
                                if (!preg_match('#^[\s"\,\$\&\A-Za-z0-9'.$add_chars.' áéíóúñÑ+-]{1,500}$#', $value)) {
                                        $error_bg[] = $field;
                                        $errors[] = htmlspecialchars($value, ENT_QUOTES).' '.$MOD_BAKERY['ERR_INVAL_STREET'];
                                }
                        }
--- End code ---

the problem with the special chars is, if you go 1 step back, maybe for repairing your adress datas, you have a entry in the textfield like this
Reuden &quot;Nord&quot;
its not a error, but i looks bad for the customer

another problem - i found a way for the <br /> in the mails, but the design is not the best. normally you have a little space in every adress line before the adress starts, like
Adress
          20 Calle 16-03
          Colonia Granai III
          Zona 11
          Guatemala, Guatemala

the adress in the database is a formated text, so i can only take the <br> from this text and put a \n on this place, but after a \n the next line starts at the begin from the next line, like
Adress
          20 Calle 16-03
Colonia Granai III
          Zona 11
          Guatemala, Guatemala

my solution is this new lines in the view_confirmation.p hp

--- Code: ---$cust_address = str_replace("<br>", "\r\n", $cust_address);
$cust_address = str_replace("<br />", "\r\n", $cust_address);
$ship_address = str_replace("<br>", "\r\n", $ship_address);
$ship_address = str_replace("<br />", "\r\n", $ship_address);

--- End code ---

in this block nearly line 122

--- Code: ---if ($customer['invoice'] != '') {
                                        // Convert string to array
                                        $invoice = stripslashes($customer['invoice']);
                                        $invoice_array = explode('&&&&&', $invoice);

                                        // Email vars to replace placeholders in the email body
                                        $setting_shop_name = $invoice_array[1];
                                        $bank_account      = $invoice_array[2];
                                        $cust_name         = $invoice_array[3];
                                        $cust_email        = $invoice_array[7];
                                        $shop_email        = $invoice_array[10];
                                        $address           = $invoice_array[11];
                                        $cust_address      = $invoice_array[12];
                                        $ship_address      = $invoice_array[13];
                                        $item_list         = $invoice_array[14];
                                        $cust_tax_no       = $invoice_array[15];
                                }
--- End code ---

copy the 4 new line to the end before the }

maybe it helps, if you set 10 or more space's in the replace-code, like


--- Code: ---$cust_address = str_replace("<br>", "          \r\n", $cust_address);
--- End code ---

but i will look for a better way and i search for the place, where the adress has been formatet

a last question: you have test the bakery Vers 1.7, have you found there the same problems with your special chars?

Bakery 1.7 works with a config.php, there are defined the $addchars
bakery 1.6 works with special chars defined in every language file

i think, you use only the english language file, please check, if you found a full entry in your EN.php
normally its empty in the EN.php

--- Code: ---$MOD_BAKERY['ADD_REGEXP_CHARS'] = '';
--- End code ---

if so in your file, replace it with

--- Code: ---$MOD_BAKERY['ADD_REGEXP_CHARS'] = 'ÁÀÂÃÄÅáà âãä寿ÇçČčÐðÉÈÊËéèêëÍÌÎÏíìîïÑñÓÒÔÕÖØóòôõöøŒœÞþÚÙÛÜúùûüŠšßÝŸýÿŽžÂ';
--- End code ---

svsanchez:
Hello Jacobi

Thank you so much for your help and teaching me how to add new special characters, I was able to add the dot character which is misssing in your example by adding \.

I'm not sure if it's an error in your example you have \s"\,\$\&\A-Za-z0-9'.$add_chars.' áéíóúñÑ+-]{1,500} so it seems like the \ is missing in front of the " but maybe \s" would also work. I changed it to \s\"\, and it worked on my test :)

Regarding the </br> it's a good solution!

As for Bakery 1.7 I have stayed away from it since it doesn't allow to "SKIP CHECKOUT IF ONLY ONE PAYMENT METHOD IS SELECTED", don't really know why the developer removed that useful feature. You see, there are many countries that don't have too many payment options and in many cases companies only want to show their products without prices but only want to allow customers to ask them for a quote, so bakery 1.6 allows me to do this pretty easily while 1.7 makes it too confusing.

Navigation

[0] Message Index

[*] Previous page

Go to full version