toplakd Posted January 22, 2021 Posted January 22, 2021 Is it possible withing carrier selection template to check if the address has phone? As I didn't have phone mandatory for 10 years, but now about 60% of shipping is switched to DHL where phone number is mandatory. And there comes the issue with old customers which ignore (or don't pay attention) to big red phone notification before proceeding to checkout step. So I would like to implement code that checks if phone exists so I can hide/show proceed buttons. {if $phoneexists-I dont know the code} Move my proceed buttons here {else} Showing warning that one should update address with phone {/if}
MichaelEZ Posted January 22, 2021 Posted January 22, 2021 (edited) {if empty($address.phone)} have number {else} dont {/if} into address.tpl in address block or above {if empty($multipleAddresses.phone)} Y {else} N {/if} Edited January 22, 2021 by MichaelEZ 1
yaniv14 Posted January 22, 2021 Posted January 22, 2021 What you need is a javascript event listener, probably "input" and/or "change" and then check the desire output and based on that show/hide input field/text display. of course this is not SAFE solution because its only front end manipulation. and its better to have a server side validation as well... which probably requires some controller override. 1
toplakd Posted January 22, 2021 Author Posted January 22, 2021 (edited) I know if its just front manipulation, but I don't need more, as otherwise I have to send email to update the address with phone and this just results as delay as I can not ship before I have phone. The above code from MichaelEZ does not work as I would like to use that checking on either Order Address Selection template or Order Carrier selection template. This is something I would need, even with override if needed. I just don't have the knowledge how to exactly form the first if sentence 😞 {if delivery address phone is empty} Show the missing phone warning {else} <div> proceed to checkout buttons </div> {/if} Edited January 22, 2021 by toplakd
toplakd Posted January 22, 2021 Author Posted January 22, 2021 (edited) For me this works on order-carrier.tpl <div class="invoice_has_phone"> {if empty($invoice->phone)} <p class="alert alert-danger"> {l s='You need to update your delivery address with one phone number'} </p> {else} <p class="cart_navigation clearfix"> ... Showing Proceed to Checkout buttons ... </p> {/if} </div> And following line added to order-address.js to reload the div when switching between addresses $('.invoice_has_phone').load(document.URL + ' .invoice_has_phone > *'); So now it works flawlessly, when switching between addresses that have or don't have the phone. If address without phone number is chosen, warning pops up and proceed buttons disappear 🙂 Will test it some more before I integrate it into live shop. I'm only using one phone number and one address for billing/delivery. Edited January 22, 2021 by toplakd 1
DRMasterChief Posted January 22, 2021 Posted January 22, 2021 Hello, incidentally, without any technical aspect, DHL will never use a telephone number for delivery. They only collect them to compare their databases and sell them to address publishers. EU data protection can be a problem in this matter!
toplakd Posted January 22, 2021 Author Posted January 22, 2021 (edited) Problem is, that I can not even create label without entered email and phone for delivery (have to enter both) Same with national Post carrier. Can not send package outside my country with regular POST without phone or email (they need only one). Mandatory from 01/01/2021 And yet when DHL, FEDEX, DPD or any other currier delivers to me, they call upfront, coming in 20 minutes, will there be anyone at delivery location, as most shops where I buy my technical stuff and tools, all have phone required. Edited January 22, 2021 by toplakd
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now