Store Terms & Conditions
#1
Posted 19 June 2010 - 12:02 AM
It's good practice, aka essential, to have the customer agree to the store T&Cs. You know, the usual stuff: no contract exists until the order is accepted, store has the right to correct pricing errors, etc. Since T&Cs can run to many pages of text it's often not customer friendly to display all of it on the checkout pages.
So, on the order review page there would usually be:
1) A link to the T&Cs (opening as a pop-up or separate window so as not to interrupt checkout flow); or
2) A list box displaying the T&Cs that the customer can scroll through; and
3) A checkbox for the customer to agree to the T&Cs before being permitted to place the order and pay.
Do you think this behaviour should be in core, or is best implemented as a customization?
Thanks
iD
#2
Posted 19 June 2010 - 05:46 PM
Thank you for the suggestion and for keeping following us! ;-)
I think it is better to not integrate the terms and conditions feature into the core. The checkout process if very flexible. There even could be no the Order Review step at all. For example, someone may want to implement a one-click checkout (that is possible, if all customer details are already known). Having the T&C feature in the core could apply limitations to the flexibility. On the other hand, implementing the T&C link and the checkbox is a very simple task - you just need to a JavaScript check to the Pay button on the last checkout step - to make sure that the customer has agreed with T&C.
Aleksey
#3
Posted 20 June 2010 - 11:17 AM
But I have a question :) How do I get the page content from an arbitrary CMS page? That is, I need to get the markup that's shown in the Content edit box of a CMS->Pages->Edit Page window.
See, I have a T&Cs CMS page that the customer can navigate to. What I want, is to use the content of that T&Cs page in a div on the order review page.
Thanks
iD
#4
Posted 20 June 2010 - 01:51 PM
You can find a page by its URL and load its content with the following code:
$page_content = Cms_Page::findByUrl('/your-tnc-page-url')->content;Thanks!
Aleksey
#5
Posted 21 June 2010 - 02:16 AM
Thanks for that. Did you just add that to the Wiki or did I miss it? ;)
Anyhow, looks like Cms_Page::findByUrl takes 2 arguments, and the 2nd, &$Params, isn't optional.
What are the params?
Thanks
iD
#6
Posted 21 June 2010 - 02:29 AM
I added the function description to the Wiki today and just updated it. Pleas pass a variable containing an empty array to the second parameter:
$params = array();
$page = Cms_Page::findByUrl('/your-page-url', $params);The findByUrl() function is used by the system for resolving pages then LemonStand gets an HTTP request. I was not going to make it public until you asked :-) If you are interested in details, the $params parameter works as follows. If you have a page with URL "/my-page", and you make the call:
$params = array();
$page = Cms_Page::findByUrl('/my-page/lemonstand', $params);the $params variable will have the following value: array('lemonstand') - an array with a single element, which value is "lemonstand". The CMS engine uses this approach to read page parameters (for example, product URL names) from the page URL and then passes the page parameters to CMS actions.
Thank you
Aleksey
#8
Posted 03 July 2010 - 06:23 PM
I got an email notification saying that you posted a question about the SCRIPT elements in the page object fetched from the database. But I cannot find this post now. Did you delete it?
#9
Posted 15 July 2010 - 09:29 AM
if i add a checkbox, what code do i need to add to the page for the payment to be blocked unless the checkbox is clicked? and how does one add an error message stating the checkbox needs to be clicked.

thanks
#10
Posted 15 July 2010 - 02:20 PM
First, you need to create the checkbox and assign it some ID value, for example "terms":
<input type="checkbox" id="terms"/>
After that you need to modify the the onclick event handler on the Place Order and Pay button. We need to add the preCheckFunction parameter - a function which will check whether the checkbox is checked. Below is updated code of the Place Order and Pay button:
<input type="image" src="<?= root_url('/resources/images/btn_place_order.gif') ?>" alt="Place Order and Pay"
onclick="return $(this).getForm().sendRequest(
'on_action', {
update:{'checkout_page': 'checkout_partial'},
preCheckFunction: function(){
if (!$('terms').checked) {
alert('Please agree before placing the order');
return false;
} else
return true;
}
})"/>Thank you
#11
Posted 19 July 2010 - 06:34 AM
#12
Posted 02 March 2011 - 07:27 AM
This is a very useful post!
Whats happens if the user did disabled the javascript from the navigator preferences? I need implement the same checkbox with the terms & cond. before complete the pay (implementing whit Authorize.net AIM).
Cheers
Luis
#13
Posted 02 March 2011 - 04:28 PM
You can process the Terms and Conditions checkbox value with the following code. Please add it to the PRE Action Code field of the Pay page:
if (post('submit_payment') && !post('agree'))
{
$_POST['submit_payment'] = false;
throw new Phpr_ApplicationException('You should agree to the terms and conditions');
}
The checkbox on the page should have the "agree" name:
<input type="checkbox" name="agree" ... />
Also, in order the Pay form to work without AJAX, the Pay button in the payment:authorize_net_aim partial should be a submit-type input element and have the submit_payment name:
<input type="submit" onclick="return $(this).getForm().sendRequest('shop:on_pay')" value="Submit" name="submit_payment"/>To process the checkbox with JavaScript please use the approach explained above.
Thanks
#15
Posted 03 December 2011 - 04:34 AM
But anway...
I cannot get above solution to work. What am I missing here?
<input type="checkbox" id="terms" name="terms" /><label for="terms">Ik ga akkoord met de algemene voorwaarden</label>
<input type="submit" value="Plaats de bestelling!" class="button_control" onclick="return $(this).getForm().sendRequest(
'on_action', { update:{'checkout_page': 'shop:checkout_partial'},
preCheckFunction: function(){
if (!$('terms').checked) {
alert('Please agree before placing the order');
return false;
} else
return true;
}
})"/>
#16
Posted 04 December 2011 - 04:39 PM
rebelsenrules, on 03 December 2011 - 04:34 AM, said:
<input type="checkbox" id="terms" name="terms" /><label for="terms">Ik ga akkoord met de algemene voorwaarden</label>
<input type="submit" value="Plaats de bestelling!" class="button_control" onclick="return $(this).getForm().sendRequest(
'on_action', { update:{'checkout_page': 'shop:checkout_partial'},
preCheckFunction: function(){
if (!$('terms').checked) {
alert('Please agree before placing the order');
return false;
} else
return true;
}
})"/>
Hi!
Your code looks properly. Does it trigger any JavaScript errors? Can you post an URL of your store?
Thank you
#17
Posted 07 December 2011 - 11:28 PM
Thank you for your reply!
The code does not trigger any JS erros, it simply returns false whether the checkbox is checked or not. Unfortunately I don't know much about JS...
The site is currently semi-live at nieuw.rebelsenrules.nl
Thanks for your help, I appreciate it!
Frank
#18
Posted 01 January 2012 - 11:10 PM
Could you please have a look at abovementioned site? I still haven't been able to fix it...
Cheers,
Frank
#19
Posted 03 January 2012 - 03:02 AM
I checked your store. You use jQuery, whereas my example was actual for MooTools. With jQuery you should use other code for checking whether a checkbox is checked:
$('#agree').is(':checked')Please replace the onclick handler code with the following:
return $(this).getForm().sendRequest(
'on_action', {
update:{
'checkout_page': 'shop:checkout_partial'
},
preCheckFunction: function() {
if (!$('#agree').is(':checked')) {
alert('U dient akkoord te gaan met de Algemene Voorwaarden.');
return false;
} else return true;
}
}
)Thank you
#20
Posted 04 April 2012 - 07:13 AM
Aleksey, on 02 March 2011 - 04:28 PM, said:
You can process the Terms and Conditions checkbox value with the following code. Please add it to the PRE Action Code field of the Pay page:
if (post('submit_payment') && !post('agree'))
{
$_POST['submit_payment'] = false;
throw new Phpr_ApplicationException('You should agree to the terms and conditions');
}
The checkbox on the page should have the "agree" name:
<input type="checkbox" name="agree" ... />
Also, in order the Pay form to work without AJAX, the Pay button in the payment:authorize_net_aim partial should be a submit-type input element and have the submit_payment name:
<input type="submit" onclick="return $(this).getForm().sendRequest('shop:on_pay')" value="Submit" name="submit_payment"/>Hi Aleksey:
For some reason this is not working for me:
1. Code placed on Pay page pre-action form.
2. Checkbox and input code on the relevant payment gateway partial.
Unfortunately the error is not thrown to warn the user and the form processes as usual.
Any ideas?
To process the checkbox with JavaScript please use the approach explained above.
Thanks

Help













