Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Message on checkout when country selected

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-18-2021, 10:30 PM
 
shaz shaz is offline
 

Senior Member
  
Join Date: Jul 2008
Location: Sydney, Australia
Posts: 174
 

Default Message on checkout when country selected

Hi There,

We require a message to appear for UK clients on the One Page Checkout when a particular country(s) is selected


For example:

Code:
{if $c.country_code eq "UK"} MESSAGE HERE {/if}

I've been able to identify the templates where I can get the message to appear but not the variable for country or country code for the IF STATEMENT.

X-Cart Version: 4.7.5

Can anyone assist? Thanks!
__________________
Shaz
X-Cart Developer
Sydney - Australia
Reply With Quote
  #2  
Old 01-19-2021, 12:15 AM
 
ITVV ITVV is online now
 

X-Wizard
  
Join Date: Nov 2006
Location: UK
Posts: 1,167
 

Default Re: Message on checkout when country selected

Hi,

Which template are you using your code?

ITVV
__________________
X-Cart Pro 4.7.12 Active and working great with reBOOT-reDUX
X-Cart Pro 4.6.6 Retired after 6 years of first class service
X-Cart Pro 4.1.7 Retired after 9 years of first class service

Apache: 2.4.25
PHP: 7.4.5
MariaDB: 10.1.44
Arch: x86_64
Reply With Quote
  #3  
Old 01-19-2021, 04:24 PM
 
shaz shaz is offline
 

Senior Member
  
Join Date: Jul 2008
Location: Sydney, Australia
Posts: 174
 

Default Re: Message on checkout when country selected

Quote:
Originally Posted by ITVV
Hi,

Which template are you using your code?

ITVV

Thanks for the quick reply

We are using xtreme_gear, however test edits are showing from editing the files in /skin/common_files/modules/One_Page_Checkout/
__________________
Shaz
X-Cart Developer
Sydney - Australia
Reply With Quote
  #4  
Old 01-20-2021, 02:11 AM
 
ITVV ITVV is online now
 

X-Wizard
  
Join Date: Nov 2006
Location: UK
Posts: 1,167
 

Default Re: Message on checkout when country selected

Hi Shaz,

Couple of points here: -

1/ United Kingdom is referenced as GB not UK

2/ No data available for $c.country_code???

Try this to give you a pointer: -

PLEASE NOTE I used Ideal Responsive as the skin because I do not have xtreme_gear

Open

Code:
skin/common_files/modules/One_Page_Checkout/opc_main.tpl

FIND: -

Code:
<h1>{$lng.lbl_checkout}</h1>

ADD THE FOLLOWING CODE ABOVE THE LINE ABOVE: -

Code:
<h1 style="background-color:powderblue;">SHAZ START <br> $userinfo.b_country = {$userinfo.b_country} <br> $userinfo.s_country = {$userinfo.s_country} <br> $userinfo.b_countryname = {$userinfo.b_countryname} <br> Here is your code: - <br><br> if $userinfo.b_country eq "GB"<br> MESSAGE HERE<br> /if <br><br> {if $userinfo.b_country eq "GB"} MESSAGE HERE<br> {/if} <br> SHAZ END</h1>

Hope that helps?

Kind regards

ITVV
__________________
X-Cart Pro 4.7.12 Active and working great with reBOOT-reDUX
X-Cart Pro 4.6.6 Retired after 6 years of first class service
X-Cart Pro 4.1.7 Retired after 9 years of first class service

Apache: 2.4.25
PHP: 7.4.5
MariaDB: 10.1.44
Arch: x86_64
Reply With Quote

The following user thanks ITVV for this useful post:
shaz (01-21-2021)
  #5  
Old 01-20-2021, 05:46 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default Re: Message on checkout when country selected

Since this is for the OPC if you add it to the template file only it will trigger the message show/not on page load only. It will not work when country is selected from the dropdown or address book (depends on the template though). OPC has a lot of js code to refresh different parts of the page on request.

The country dropdown triggers onChange event to properly display states field - this is where you want to add your message too to either pop or show directly on page. I think the file to modify is skin/common_files/js/change_states.js

You also have to modify skin/common_files/modules/One_Page_Checkout/ajax.checkout.js to show/hide the message if address is selected from the address book
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #6  
Old 01-21-2021, 04:21 PM
 
shaz shaz is offline
 

Senior Member
  
Join Date: Jul 2008
Location: Sydney, Australia
Posts: 174
 

Default Re: Message on checkout when country selected

Thanks ITVV

Yes, adding the below code to skin/common_files/modules/One_Page_Checkout/opc_main.tpl and /skin/xtreme_gear/modules/One_Page_Checkout/profile/address_info.tpl gets it to display, however Steve is correct... only if the country is loaded by default with the cart, or a page refresh.

{if $userinfo.b_country eq "GB"}
<h3 style="color:red;">MESSAGE HERE</h3>
{/if}

I was an x-cart 4 dev in a past life now so geting into the ajex/js is now a bit beyond me these days I'm afraid!
__________________
Shaz
X-Cart Developer
Sydney - Australia
Reply With Quote

The following user thanks shaz for this useful post:
ITVV (01-21-2021)
  #7  
Old 01-21-2021, 05:02 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Message on checkout when country selected

Your GB Message put somewhere...
Code:
<div id="GB_Message" style="display:none"> Message for GB customers... </div>
CSS...
Code:
#GB_Message { color: red; font-size: 20px; }
Script...
Code:
<script> $(document).ready(function() { var $selectedCountry = $('select#b_country').val(); if ($selectedCountry == 'GB') { $('#GB_Message').removeAttr('style');// Show message } else { $('#GB_Message').css('display', 'none');// Hide message } $('select#b_country').on('change', function() { var $modifiedCountry = $(this).val(); if ($modifiedCountry == 'GB') { $('#GB_Message').removeAttr('style');// Show message } else { $('#GB_Message').css('display', 'none');// Hide message } }); }); </script>
Untested, but should probably work...
__________________
xcartmods.co.uk
Reply With Quote

The following 3 users thank PhilJ for this useful post:
elmirage001 (02-01-2021), ITVV (01-21-2021), shaz (01-31-2021)
  #8  
Old 01-31-2021, 07:55 PM
 
shaz shaz is offline
 

Senior Member
  
Join Date: Jul 2008
Location: Sydney, Australia
Posts: 174
 

Default Re: Message on checkout when country selected

Thanks also xcartmods.so.uk !

Final code added to opc_main.tpl to target the UK and Ireland to work around their new VAT rule of it not applying to orders over 135 pounds.

Quote:
<script>
$(document).ready(function() {
var $selectedCountry = $('select#b_country').val();
if ($selectedCountry == 'GB' || $selectedCountry == 'IE') {
$('#GB_Message').removeAttr('style');// Show message

} else {
$('#GB_Message').css('display', 'none');// Hide message
}
$('select#b_country').on('change', function() {
var $modifiedCountry = $(this).val();
if ($modifiedCountry == 'GB' || $modifiedCountry == 'IE') {
$('#GB_Message').removeAttr('style');// Show message
} else {
$('#GB_Message').css('display', 'none');// Hide message
}
});
});
</script>

<div id="GB_Message" style="display:none">
<h3 style="color:red;">UK RESIDENTS: Meessage here</h3>
</div>

Appreciate the assistance
__________________
Shaz
X-Cart Developer
Sydney - Australia
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:48 PM.

   

 
X-Cart forums © 2001-2020