Making a secret coded give a product a special offer price (tested with 6.1.2) and IE6 only! This patch allows a set of secret discount codes that can be used to but a hidden product (that is a discounted duplicate of a normal product). It will not work on Single Add To Cart type pages so don't use on these. Products using Push Button add to cart tables are not supported either. CHANGE LOG Amended (09/09/03) To allow for Other Info and date Prompts, Components, Attributes using Select or Radio buttons. Push button tables are not supported. Also optionally displays discounted product price. Error message on wrong code. Original (08/-9/03) Only works on simple products with no prompts or attributes. INSTRUCTIONS In the following example our secret code is any off 'codexyz', 'abcpqr', 'wowza123' (without the quotes). Our duplicate discounted products with have their product references suffixed with '-nhr'. We're allowing for up to 10 components and / or attributes per product. Put the following code into actiniccore.js (at the very bottom):- // Secret Code Helper JavaScript - The next 4 lines are user modifiable. var secretsuffix = '-nhr'; // the product reference suffix suffix for our hidden items var secretcode = ['codexyz', 'abcpqr', 'wowza123']; // list of valid codes - you can add more if required - change this to suit your needs var variantcount = 10; // the max number of Components and Attributes we'll be using on such products var badcodemsg = 'Bad Code'; // the error message if incorrect code entered // some globals that may change with future versions of Actinic. var prompts = ['Q_', 'O_', 'DAY_', 'M_', 'Y_']; // our current set of prompts function formfield(fname){ // look through all forms 'till one containing field "fname" - warn if not found var df = document.forms; // simplified version - only return object fname var i = df.length - 1; for ( var j = 0; j <= i; j++ ) { var k = df[j].length - 1; for ( var l = 0; l <= k; l++ ) { if ( df[j].elements[l].name == (fname) ) { return df[j].elements[l]; } } } alert('Cannot find field ' + fname); // shouldn't happen... return false; } function findfield(fname){ // look through all forms 'till one containing field "fname" - no error if not found var df = document.forms; // simplified version - only return object fname var i = df.length - 1; for ( var j = 0; j <= i; j++ ) { var k = df[j].length - 1; for ( var l = 0; l <= k; l++ ) { if ( df[j].elements[l].name == (fname) ) { if ( df[j].elements[l].type != 'radio' ) return df[j].elements[l]; // return element if ( df[j].elements[l].checked ) return df[j].elements[l]; // or selected radio item } } } return false; } function secretcodecheck(submitimage, prodref){ var enteredvalue = formfield('SC_' + prodref).value; // the customer entered value from out visible full price product var secretvalue = ''; var secretcodecount = secretcode.length; for ( var i = 0; i < secretcodecount; i++ ) { if ( enteredvalue == secretcode[i] ) secretvalue = secretsuffix; // if we have a valid code then get the hidden suffix } if ( (enteredvalue != '') && (secretvalue == '') ) { alert(badcodemsg); return false; } submitimage.name = prodref + secretvalue; // alter the submit images name to match our invisible product // now rename the the prompts (if there are any) var promptcount = prompts.length; for ( i = 0; i < promptcount; i++) { var thisprompt = findfield(prompts[i] + prodref); if ( thisprompt ) thisprompt.name += secretvalue; // rename with the suffix } // now the variants - we've hidden fields set up so change their values to match the visible product for ( var i = 1; i <= variantcount; i++ ) { var thisvariant = findfield('v_' + prodref + '_' + i ); if ( thisvariant.type == 'checkbox' ) { if ( thisvariant.checked ) formfield('v_' + prodref + secretvalue + '_' + i ).value = 'on'; } else { if ( thisvariant ) formfield('v_' + prodref + secretvalue + '_' + i ).value = thisvariant.value; } } return true; } function makevariants(prodref){ // make the hidden fields for up to product variants on our hidden product. for ( var i = 1; i <= variantcount; i++ ) { document.write(''); } } Save the following code as SecretCode_ProductLine.html This is a standard product template with the NETQUOTEVAR:ADDTOCARTBUTTON replaced by a code field, a custom submit button with some javascript on the button click. NETQUOTEVAR:INCLUDE Act_ProductSeparator.html NETQUOTEVAR:ENDSEPARATOR NETQUOTEVAR:PRODUCTFORMBEGIN NETQUOTEVAR:TEMPLATEBEGINXML NETQUOTEVAR:PRODUCTIMAGE NETQUOTEVAR:PRODUCTNAME NETQUOTEVAR:PRODUCTREF
NETQUOTEVAR:PRODUCTDESCRIPTION NETQUOTEVAR:EXTINFOLINK
NETQUOTEVAR:EXTINFOBUTTON
NETQUOTEVAR:PRODUCTBEGINLINKNETQUOTEVAR:PRODUCTLINKTEXTNETQUOTEVAR:PRODUCTENDLINK NETQUOTEVAR:PRICEEXPLANATION
NETQUOTEVAR:PRODUCTPRICE NETQUOTEVAR:OTHERINFOPROMPT NETQUOTEVAR:DATEPROMPT NETQUOTEVAR:VARIANTS NETQUOTEVAR:CARTERRORXMLNETQUOTEVAR:PRODUCTQUANTITY
Secret discount code
NETQUOTEVAR:TEMPLATEENDXML NETQUOTEVAR:PRODUCTFORMEND NETQUOTEVAR:NEXT Save the following code as Invisible_ProductLine.html This is a dummy product template with EVERYTHING commented out so the product is invisible except for a block (that can be removed) that displays the discounted price. NETQUOTEVAR:ENDSEPARATOR NETQUOTEVAR:PRICEEXPLANATION
For discount code customers - NETQUOTEVAR:PRODUCTPRICE NETQUOTEVAR:NEXT Go into Actinic and turn off "Auto Generate Product References" in View / Business Settings / Options. That's all the setup done. Now for each discounted product:- Now create your usual product at the full price. Use SecretCode_ProductLine.html as it's template. Set its product reference to (e.g.) ABC101. Duplicate that product and place the duplicate immediately below the main one. Set the price to be your discounted one. Set its product reference to be the same as the one above but with the secretsuffix added (e.g.) ABC101-nhr Use Invisible_ProductLine.html as it's template. If you change the product (adding / removing prompts, components or attributes) be sure to make the same changes to the invisible discounted one as this MUST have an identical structure to the main product. The customer will only see the usual full priced product with an additional secret code input field. In addition there's an optional display of the discounted product price. You can edit this out in Invisible_ProductLine.html If they enter any of the the correct codes then the form submission will be altered to select the invisible discounted poroduct. If the wrong code then the they get an error message.