WordPress Simple Paypal Shopping Cart
"dropdown-button" with variations (4 posts)

  1. klarabara
    Posted 3 years ago #

    Thanks for a wonderful plugin!

    I'm implementing this on a site with twitter-bootstrap and I want to use the select variations (just one variation) to a button like these: http://twitter.github.io/bootstrap/components.html#buttonDropdowns

    instead of a dropdown and a selectlist.. However the markup needed for this to work is just a-link not <select> and <option>. I can make the options come out alright and also submit using onchange="this.form.submit()" but the values are not coming along when it does it also submits the "add to cart" -option and adds it to the cart.

    Is there a way to sort the javascript to use the values in this kind of dropdown?


  2. mra13
    Plugin Author

    Posted 3 years ago #

    As long as you can add the following to the form that you are creating you should be fine:

    onchange="ReadForm (this.form, false);"

    It is basically calling a JavaScript function named "ReadForm"

  3. klarabara
    Posted 3 years ago #

    Thankyou, I was hoping it would be that easy!

    Out of curiousity:
    Do I need to make my edits in the plugin-file or is this something I can put in my functions-file, for future updates I mean?


  4. klarabara
    Posted 3 years ago #

    Still cant get it to work and I think it is partly because this new dropdown button needs to also be the submit-button?

    Also I get this error in the console:
    TypeError: 'undefined' is not an object (evaluating 'obj1.length')

    This is the output of my button:

    <div class="wp_cart_button_wrapper btn">
    	<form method="post" class="wp-cart-button-form" action="" style="display:inline" onsubmit="return ReadForm(this, true);">
    		<div class="btn-group">
    			<a name="variation1" onchange="ReadForm(this.form, false);" class="btn dropdown-toggle" data-toggle="dropdown" >Add to cart <span class="caret"></span></a>
    			<ul class="dropdown-menu">
    				<li><a value="S ">S </a></li>
    				<li><a value=" M "> M </a></li>
    				<li><a value=" L"> L</a></li>
    				<br />
    				<input class="btn" type="submit" value="Add to Cart" />
    				<input type="hidden" name="product" value="En helt ny" />
    				<input type="hidden" name="price" value="14" />
    				<input type="hidden" name="product_tmp" value="En helt ny" />
    				<input type="hidden" name="shipping" value="10" />
    				<input type="hidden" name="cartLink" value="http://localhost/wordpress/shop-merchandise/" />
    				<input type="hidden" name="addcart" value="1" />

    If I add a normal button below to submit it sends without the variation..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic