WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. klarabara
    Member
    Posted 10 months ago #

    Hi!
    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?

    http://wordpress.org/extend/plugins/wordpress-simple-paypal-shopping-cart/

  2. mra13
    Member
    Plugin Author

    Posted 10 months 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
    Member
    Posted 10 months 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?

    *starstruck*

  4. klarabara
    Member
    Posted 10 months 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>
    				</ul>
    				</div>
    				<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" />
    		</form>
    </div>

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

Reply

You must log in to post.

About this Plugin

About this Topic