[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!!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 14:57:29
Script start
Timing: Jan 18 2025 14:57:29
Module start 'layout'
Timing: Jan 18 2025 14:57:29
Module start 'content'
Timing: Jan 18 2025 14:57:30
Module end 'content'
Timing: Jan 18 2025 14:57:30
Script end

Main resources:

Total runtime1.0410 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.0469152.6406
Module start 'layout' 0.00600.0037 740.687539.4922
Module start 'content' 0.00981.0295 780.1797604.6875
Module end 'content' 1.03920.0017 1,384.867216.1250
Script end 1.0410  1,400.9922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3383160.0002
Check MTime0.00150.1421160.0001
Mysql Total
Database connection0.00110.103810.0011
Mysqli_queries0.972793.4439620.0157
Looping result0.00090.0892600.0000
Template Total0.999396.020.4997
Template load0.00210.205520.0011
Template processing0.997295.790720.4986
Template load and register function0.00010.013110.0001
states
state_id_array0.00150.139610.0015
state_identifier_array0.00170.161920.0008
Override
Cache load0.00180.1745390.0000
Sytem overhead
Fetch class attribute can translate value0.00060.058430.0002
Fetch class attribute name0.00130.128160.0002
XML
Image XML parsing0.00120.115330.0004
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00380.3694240.0002
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs