Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Buttons that automatically add 5, 10 or 15 tickets to cart */
- /* to use this HTML / PHP code, copy it to your child theme functions.php file */
- add_action( 'woocommerce_after_add_to_cart_button', 'additional_simple_add_to_cart', 20 );
- function additional_simple_add_to_cart() {
- global $product;
- if ( wc_lottery_use_answers( $product->get_id() ) ): ?>
- <script>
- jQuery(document).ready(function($){
- $(document).on('click','.lottery-pn-answers li',function(e){
- var answer_id = $(this).data('answer-id');
- var aelement = $('a.single_add_to_cart_button-5');
- var old_url = aelement.attr("href");
- var new_url = old_url + "&lottery_answer="+answer_id;
- aelement.attr("href", new_url);
- var aelement = $('a.single_add_to_cart_button-10');
- var old_url = aelement.attr("href");
- var new_url = old_url + "&lottery_answer="+answer_id;
- aelement.attr("href", new_url);
- var aelement = $('a.single_add_to_cart_button-15');
- var old_url = aelement.attr("href");
- var new_url = old_url + "&lottery_answer="+answer_id;
- aelement.attr("href", new_url);
- });
- });
- </script>
- <?php endif; ?>
- <br><br>
- <a rel="no-follow" href="?add-to-cart=<?php echo esc_attr( $product->get_id() ) ?>&quantity=5" class="single_add_to_cart_button-5 button alt">Add 5 Tickets</a>
- <a rel="no-follow" href="?add-to-cart=<?php echo esc_attr( $product->get_id() ) ?>&quantity=10" class="single_add_to_cart_button-10 button alt">Add 10 Tickets</a>
- <a rel="no-follow" href="?add-to-cart=<?php echo esc_attr( $product->get_id() ) ?>&quantity=15" class="single_add_to_cart_button-15 button alt">Add 15 Tickets</a>
- <?php
- }
Advertisement
Comments
-
- When the product is A-Z Alphabet is there a way to "Select all from J" etc
- So people can select all of the numbers from that alphabet.
Add Comment
Please, Sign In to add comment
Advertisement