Last active
August 5, 2025 09:31
-
-
Save webaware/6260468 to your computer and use it in GitHub Desktop.
Revisions
-
webaware revised this gist
Mar 30, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ function custom_woo_loop_add_to_cart_link($button, $product) { $button = ob_get_clean(); // modify button so that AJAX add-to-cart script finds it $replacement = sprintf('data-product_id="%d" data-quantity="1" $1 ajax_add_to_cart add_to_cart_button product_type_simple ', $product->id); $button = preg_replace('/(class="single_add_to_cart_button)/', $replacement, $button); } } -
webaware revised this gist
Mar 11, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,7 +45,7 @@ function custom_woo_after_shop_loop() { <?php /* when product quantity changes, update quantity attribute on add-to-cart button */ ?> $("form.cart").on("change", "input.qty", function() { $(this.form).find("button[data-quantity]").data("quantity", this.value); }); <?php /* remove old "view cart" text, only need latest one thanks! */ ?> -
webaware revised this gist
Mar 18, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * start the customisation */ function custom_woo_before_shop_link() { add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2); add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop'); } add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link'); -
webaware revised this gist
Mar 18, 2014 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * start the customisation */ function custom_woo_before_shop_link() { add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10); add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop'); } add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link'); @@ -13,10 +13,9 @@ function custom_woo_before_shop_link() { * customise Add to Cart link/button for product loop * @param string $button * @param object $product * @return string */ function custom_woo_loop_add_to_cart_link($button, $product) { // not for variable, grouped or external products if (!in_array($product->product_type, array('variable', 'grouped', 'external'))) { // only if can be purchased -
webaware revised this gist
Nov 2, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,12 +45,12 @@ function custom_woo_after_shop_loop() { jQuery(function($) { <?php /* when product quantity changes, update quantity attribute on add-to-cart button */ ?> $("form.cart").on("change", "input.qty", function() { $(this.form).find("button[data-quantity]").attr("data-quantity", this.value); }); <?php /* remove old "view cart" text, only need latest one thanks! */ ?> $(document.body).on("adding_to_cart", function() { $("a.added_to_cart").remove(); }); -
webaware created this gist
Aug 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ <?php /** * start the customisation */ function custom_woo_before_shop_link() { add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 3); add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop'); } add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link'); /** * customise Add to Cart link/button for product loop * @param string $button * @param object $product * @param array $link * @return string */ function custom_woo_loop_add_to_cart_link($button, $product, $link) { // not for variable, grouped or external products if (!in_array($product->product_type, array('variable', 'grouped', 'external'))) { // only if can be purchased if ($product->is_purchasable()) { // show qty +/- with button ob_start(); woocommerce_simple_add_to_cart(); $button = ob_get_clean(); // modify button so that AJAX add-to-cart script finds it $replacement = sprintf('data-product_id="%d" data-quantity="1" $1 add_to_cart_button product_type_simple ', $product->id); $button = preg_replace('/(class="single_add_to_cart_button)/', $replacement, $button); } } return $button; } /** * add the required JavaScript */ function custom_woo_after_shop_loop() { ?> <script> jQuery(function($) { <?php /* when product quantity changes, update quantity attribute on add-to-cart button */ ?> $("form.cart input.qty").on("change", function() { $(this).closest("form").find("button[data-quantity]").attr("data-quantity", this.value); }); <?php /* remove old "view cart" text, only need latest one thanks! */ ?> $("body").on("adding_to_cart", function() { $("a.added_to_cart").remove(); }); }); </script> <?php }