Forums / Setup & design / [closed] shop checkout -> checkbox to accept therms

[closed] shop checkout -> checkbox to accept therms

Author Message

scrieler _

Wednesday 13 May 2009 11:31:49 pm

heya,

I want to have a checkbox to accept the therms before confirm order,
do you have an idea?

kracker (the)

Thursday 14 May 2009 12:56:16 am

Hello M M,

Why not create a new extension containing a workflow event which provides this functionality assigned to the shop -> confirm order. This should be relatively simple to start with so many examples of how to use ez's php workflow event type api.

Imagine a workflow event as a wrapper for a call to a php script or method which together provide a way to display a template of terms confirmation to a user (shop checkout step) with a form which submits back to the checkoutprocess the results of the terms which can be evaluated, stored and if successful continue though towards the completion of the checkout process.

I describe a simple extra page in checkout process but with two different workflow event types and a custom module you could also process the checkbox say during the default order confirmation page as an alternative (which requires only a little more work).

Here is some useful related information.
Please let me know how this finds you.

[0] http://ezpedia.org/en/ez/workflow
[1] http://ezpedia.org/ez/workflow_event_type
[2] http://svn.projects.ez.no/bcstaticshipping/trunk/extension/bcstaticshipping/eventtypes/event/bcstaticshipping/bcstaticshippingtype.php

Cheers,
<i>//kracker

KiD CuDi - Day N Night (Lunice Remix)</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Pascal Specht

Thursday 14 May 2009 3:05:05 am

Another way of doing it is to override the shop checkout template and add a checkbox and the corresponding texts in a div, and use some Javascript to hide/show and validate the process:

I copied parts of my shop/confirmorder.tpl below:

shop/confirmorder.tpl:

this displays the checkbox and triggers a javascript: $tac and $tac_url are the text to be shown, and a link to the terms and conditions.

<input type="checkbox" id="tacCB" onclick="displayTACWarning()" name="tac" value="{$tac|wash}" {section show=$tac|eq(1)} checked="checked"{/section}/>

the text and link is just behind the checkbox, as shown here:

<label for="tacCB" style="display: inline;">{"I have read the"|i18n("bg_user/confirmorder")}</label> {if $tac_url}<a href={$tac_url|ezurl} target="_blank">{/if}{"terms and conditions"|i18n("bg_user/confirmorder")}{if $tac_url}</a>{/if} {"and I agree"|i18n("bg_user/confirmorder")}

the following part is a div that is sohwn only if the user tries to commit the order without clicking on the terms and conditions:

<div class="break"><!--  --></div>
<div id="noTACwarning" {section show=$showtac|eq(0)} style="display:none;" {/section} class="warning" "style="height:100px;">
{"You need to agree to the terms and conditions in order to proceed"|i18n("bg_user/confirmorder")}
</div>
<br />

and below, you'll find the Javascript that I use to trigger/change the visibility state of the warning, and the way the commit button works, depending on the ceckboxes' state.

{run-once}
{literal}

	<script language='javascript' type='text/javascript'>
	function submitform( ok )
	{
	  var obj = document.getElementById("jsfakebutton");
	  var tacCB = document.getElementById("tacCB");
	  var tac_agreed = tacCB.checked;
	  if ( ok )
	  {
		obj.name="ConfirmOrderButton";
		{/literal}
		obj.value="{'Confirm'|i18n('design/standard/shop')}";
		{literal}
	  }
	  else
	  {
		obj.name="CancelButton"; 
		{/literal}
		obj.value="{'Cancel'|i18n('design/standard/shop')}";
		{literal}
	  }

	  if (ok && !tac_agreed )
	  {
	     displayTACWarning();
	  }
	  else
	  {
		document.ConfirmOrder.submit();
	  }
	}

	var existingOnload = null;
	if (window.onload) { existingOnload = window.onload; }

	window.onload = function (ev) {
		if (existingOnload) { existingOnload(ev); }
        showjavascriptbuttons();
	}
	
	function displayTACWarning() {
	   var tacCB = document.getElementById("tacCB");
	   var tac_agreed = tacCB.checked;
	   var vis = (tac_agreed) ? "none" : "block";
	   document.getElementById( 'noTACwarning' ).style.display = vis;
	}

	function showjavascriptbuttons() {
		document.getElementById( 'javabuttons' ).style.display = "block";
	}
    
   </script>
{/literal}
{/run-once}

I hope this helps you getting the code quickly on the rails,

</Pascal>

scrieler _

Tuesday 19 May 2009 6:42:24 am

I got it, yeah =)

thank you very much Pascal!!!

thanks a lot to kracker too!!

eZ debug

Timing: Jan 30 2025 20:30:14
Script start
Timing: Jan 30 2025 20:30:14
Module start 'content'
Timing: Jan 30 2025 20:30:14
Module end 'content'
Timing: Jan 30 2025 20:30:15
Script end

Main resources:

Total runtime0.3738 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 588.0781370.2734
Module start 'content' 0.00880.0128 958.35161,005.7031
Module end 'content' 0.02160.3522 1,964.05473,893.6641
Script end 0.3738  5,857.7188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00471.2675200.0002
Check MTime0.00130.3539200.0001
Mysql Total
Database connection0.00060.169610.0006
Mysqli_queries0.268071.69841410.0019
Looping result0.00160.43851390.0000
Template Total0.351894.110.3518
Template load0.00080.220710.0008
Template processing0.351093.882510.3510
Override
Cache load0.00060.154610.0006
Sytem overhead
Fetch class attribute can translate value0.00180.474610.0018
XML
Image XML parsing0.00030.068510.0003
General
dbfile0.01082.8972200.0005
String conversion0.00000.001630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs