WebsiteBaker Support (2.8.x) > Bakery Shop

Bakery Second Address line field

(1/3) > >>

svsanchez:
Hello community, I am running into trouble with the address field as there is only one text field. I would like to know if it's possible to add a second address line or to modify the text field into a text area? I tried using the custom fields but it seems it's not possible to use them for the address?

Thank you!

jacobi22:
i think, custom fields are only for the product page, not for the form
its no problem, to change the second line to a textarea, but you have to change the control check for this field too (only 50 chars for this field)

svsanchez:
Hello Jacobi, thank you for your reply. Where can I change the field type and the control check?

jacobi22:
i think, bakery 1,6??

i talk a little too fast  :oops: :lol:

bakery goes into a loop for the form, so it can be flexible or dynamic in the form, so its not possible to change only one input field only

i test this way: i use textarea's for all input areas, textareas has a standard min-height from 3 rows,(if you not define a seperat height) so i change the area-height with css. i put p{NAME} into the class, so that you have CSS-classes like pcust_email, pcust_confirm_email etc
(watch the p before the field btw class names!)
Look into the source code from the Form for the correct textarea names

for Vers 1.60 only!
File: modules/bakery/templates/form/form.htm // line 23 - 28
original code

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

--- End code ---

new code

--- Code: ---<!-- BEGIN cust_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 ---

in the frontend.css i build new classes like  pcust_email, pcust_confirm_email etc

with these entry for a smaler input area / input field - in the eample for all input fields but not for the last name


--- Code: ---.pcust_email, .pcust_confirm_email, .pcust_first_name, .pcust_street, .pcust_zip, .pcust_city {height:14px;}
--- End code ---

if you want you can set the text on the left side from the textarea to the top in this row with this entry in the frontend.css

--- Code: ---tr#cust_last_name_text {
        vertical-align:top;
}
--- End code ---


bakery 1.60 check the form in the view.php , nearly line 474

here the original code  for the field "last name"

--- Code: ---if (strpos($field, 'last_name') !== false) {
                                if (!preg_match('#^[A-Za-z'.$add_chars.' -]{1,50}$#', $value)) {
                                        $error_bg[] = $field;
                                        $errors[] = htmlspecialchars($value, ENT_QUOTES).' '.$MOD_BAKERY['ERR_INVAL_NAME'];
                                }
                        }
--- End code ---

change the 50 in line 2 from this code here with your max chars for this textarea
maybe from {1,50} to {1,300}

then go to view_form.php to this lines 147 - 190 and set the max lenght for your field (4 x)
in my eample i will have the field "last name" as a textarea with 300 chars as max, so i need to change this part here
from "cust_last_name" => "50", to "cust_last_name" => "300", in line 172, 176, 184 and line 188

here the original code from the view_form.php without these changes


--- Code: ---// Make array for the customer address form with state field
if ($setting_state_field == "show") {
        if ($setting_zip_location == "end") {
                // Show zip at the end of address
                $cust_info = array("cust_email" => $MOD_BAKERY['TXT_CUST_EMAIL'], "cust_confirm_email" => $MOD_BAKERY['TXT_CUST_CONFIRM_EMAIL'], "cust_first_name" => $MOD_BAKERY['TXT_CUST_FIRST_NAME'], "cust_last_name" => $MOD_BAKERY['TXT_CUST_LAST_NAME'], "cust_tax_no" => $MOD_BAKERY['TXT_CUST_TAX_NO'], "cust_street" => $MOD_BAKERY['TXT_CUST_ADDRESS'], "cust_city" => $MOD_BAKERY['TXT_CUST_CITY'], "cust_state" => $MOD_BAKERY['TXT_CUST_STATE'], "cust_zip" => $MOD_BAKERY['TXT_CUST_ZIP'], "cust_country" => $MOD_BAKERY['TXT_CUST_COUNTRY'], "cust_phone" => $MOD_BAKERY['TXT_CUST_PHONE']);
                $length = array("cust_email" => "50", "cust_confirm_email" => "50", "cust_first_name" => "50", "cust_last_name" => "50", "cust_tax_no" => "20", "cust_street" => "50", "cust_zip" => "10", "cust_city" => "50", "cust_state" => "50", "cust_phone" => "20");
        } else {
                // Show zip inside of address
                $cust_info = array("cust_email" => $MOD_BAKERY['TXT_CUST_EMAIL'], "cust_confirm_email" => $MOD_BAKERY['TXT_CUST_CONFIRM_EMAIL'], "cust_first_name" => $MOD_BAKERY['TXT_CUST_FIRST_NAME'], "cust_last_name" => $MOD_BAKERY['TXT_CUST_LAST_NAME'], "cust_tax_no" => $MOD_BAKERY['TXT_CUST_TAX_NO'], "cust_street" => $MOD_BAKERY['TXT_CUST_ADDRESS'], "cust_zip" => $MOD_BAKERY['TXT_CUST_ZIP'], "cust_city" => $MOD_BAKERY['TXT_CUST_CITY'], "cust_state" => $MOD_BAKERY['TXT_CUST_STATE'], "cust_country" => $MOD_BAKERY['TXT_CUST_COUNTRY'], "cust_phone" => $MOD_BAKERY['TXT_CUST_PHONE']);
                $length = array("cust_email" => "50", "cust_confirm_email" => "50", "cust_first_name" => "50", "cust_last_name" => "50", "cust_tax_no" => "20", "cust_street" => "50", "cust_zip" => "10", "cust_city" => "50", "cust_state" => "50", "cust_phone" => "20");
        }
}
// Make array for the customer address form w/o state field
else {
        if ($setting_zip_location == "end") {
                // Show zip at the end of address
                $cust_info = array("cust_email" => $MOD_BAKERY['TXT_CUST_EMAIL'], "cust_confirm_email" => $MOD_BAKERY['TXT_CUST_CONFIRM_EMAIL'], "cust_first_name" => $MOD_BAKERY['TXT_CUST_FIRST_NAME'], "cust_last_name" => $MOD_BAKERY['TXT_CUST_LAST_NAME'], "cust_tax_no" => $MOD_BAKERY['TXT_CUST_TAX_NO'], "cust_street" => $MOD_BAKERY['TXT_CUST_ADDRESS'], "cust_city" => $MOD_BAKERY['TXT_CUST_CITY'], "cust_zip" => $MOD_BAKERY['TXT_CUST_ZIP'], "cust_country" => $MOD_BAKERY['TXT_CUST_COUNTRY'], "cust_phone" => $MOD_BAKERY['TXT_CUST_PHONE']);
                $length = array("cust_email" => "50", "cust_confirm_email" => "50", "cust_first_name" => "50", "cust_last_name" => "50", "cust_tax_no" => "20", "cust_street" => "50", "cust_zip" => "10", "cust_city" => "50", "cust_phone" => "20");
        } else {
                // Show zip inside of address
                $cust_info = array("cust_email" => $MOD_BAKERY['TXT_CUST_EMAIL'], "cust_confirm_email" => $MOD_BAKERY['TXT_CUST_CONFIRM_EMAIL'], "cust_first_name" => $MOD_BAKERY['TXT_CUST_FIRST_NAME'], "cust_last_name" => $MOD_BAKERY['TXT_CUST_LAST_NAME'], "cust_tax_no" => $MOD_BAKERY['TXT_CUST_TAX_NO'], "cust_street" => $MOD_BAKERY['TXT_CUST_ADDRESS'], "cust_zip" => $MOD_BAKERY['TXT_CUST_ZIP'], "cust_city" => $MOD_BAKERY['TXT_CUST_CITY'], "cust_country" => $MOD_BAKERY['TXT_CUST_COUNTRY'], "cust_phone" => $MOD_BAKERY['TXT_CUST_PHONE']);
                $length = array("cust_email" => "50", "cust_confirm_email" => "50", "cust_first_name" => "50", "cust_last_name" => "50", "cust_tax_no" => "20", "cust_street" => "50", "cust_zip" => "10", "cust_city" => "50", "cust_phone" => "20");
        }
}
--- End code ---

after all theses changes you have to restart the view.php (if the shop site is open in the browser) and maybe clear the browser cache for the new max lengt in the textarea, otherwise it comes a error message, that the input is not the correct entry for this field.

P.S.: everything here is testet with bakery 1.60 in a wb 2.8.3 on a server with PHP 5.5.3

another p.s.:  remember, that the long entry goes to other parts from bakery, so to the invoices, the mails, the payment methodes, so you have to check the design and output for this long text input in other pages or documents

svsanchez:
Hmmm, thank you Jacobi, looks a little complicated but I guess I will be able to do this with your step by step instructions. I will post here my results :)

Navigation

[0] Message Index

[#] Next page

Go to full version