Rich-text Reply

Looking for ideas on how to add a button to a shopping cart page.

AlanJulich 01-19-16

Looking for ideas on how to add a button to a shopping cart page.

Just want to test a "Save Cart" button that doesn't currently exist. Any thoughts would be great.   The visual editor is great for creating variations from what's already on the page but what if the object you want to test is not there and needs to be created.

Many thanks.

JDahlinANF 01-19-16
 

Re: Looking for ideas on how to add a button to a shopping cart page.

I presume the saveCart feature already exists and you are merely looking at how to add a button that calls the feature.  For this, you will want to use your browser's console to test out creating the button using JavaScript and, once satisfied with the button's location and appearance, you will place all of that code into the "vartiation code" section of the variation (bottom right corner of the editor)

 

For clarity's sake, let's presume that you can save the cart by calling  the javascript function"saveCart()".

I'll use super-basic HTML here so that it's easy to read - yours will of course be much nicer looking.

 

1- create the HTML that is the button:

var saveCartButton = "<button type='button' id='btn_SaveCart'>Save Cart!</button>";

2- Find the location of the page where you want to add the button, let's pretend you want to add it to the bottom of the div that has id="content":

$('#content').append(saveCartButton);

3- Now to add the code that calls the "saveCart" function when a user clicks on the button

$('#btn_SaveCart').on('click',function(){ saveCart(); }

So in the "variation code" block, you would enter:

var saveCartButton = "<button type='button' id='btn_SaveCart'>Save Cart!</button>";
$('#content').append(saveCartButton);
$('#btn_SaveCart').on('click',function(){ saveCart(); });