X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Message on checkout when country selected (https://forum.x-cart.com/showthread.php?t=78118)

shaz 01-18-2021 10:30 PM

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!

ITVV 01-19-2021 12:15 AM

Re: Message on checkout when country selected
 
Hi,

Which template are you using your code?

ITVV

shaz 01-19-2021 04:24 PM

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/

ITVV 01-20-2021 02:11 AM

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

cflsystems 01-20-2021 05:46 AM

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

shaz 01-21-2021 04:21 PM

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!

PhilJ 01-21-2021 05:02 PM

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...

shaz 01-31-2021 07:55 PM

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


All times are GMT -8. The time now is 04:17 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.