Created
August 8, 2018 18:30
-
-
Save dasbairagya/70b4b2bcc611d1571f624bd89c126ec1 to your computer and use it in GitHub Desktop.
Woocommerce customization through hook
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 characters
| <?php | |
| // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Woocommerce Customization-=-=-=-=-=-=-=-=-=-=-= | |
| // @customization files: followed by .php | |
| # wc>loop>rating | |
| # wc>loop>price | |
| # wc>loop>add-to-cart | |
| # wc>content-product | |
| # wc>content-single-product | |
| # wc>archive-product | |
| # wc>single-product>add-to-cart>variation-add-to-cart-button | |
| # wc>single-product>add-to-cart>simple | |
| # wc>single-product>rating | |
| # wc>cart>cart | |
| # wc>cart>proceed-to-chekout-button | |
| # wc>checkout>payment | |
| // --------------------------------------------------------------------------------- | |
| // @Product page | |
| add_filter( 'woocommerce_show_page_title', '__return_false' ); | |
| remove_action( 'woocommerce_before_shop_loop', 'wc_print_notices', 10 ); | |
| remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); | |
| remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); | |
| add_action('woocommerce_before_shop_loop','catalog_wrapper',20); | |
| function catalog_wrapper(){ | |
| echo '<div class="row"><div class="col-md-10">'; | |
| woocommerce_result_count(); | |
| echo '</div><div class="col-md-2">'; | |
| woocommerce_catalog_ordering(); | |
| echo '</div></div><div class="mb-5x"></div>'; | |
| } | |
| remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10); | |
| add_action('woocommerce_shop_loop_item_title','mycustom_product_title',10); | |
| function mycustom_product_title() { | |
| echo'<h3>'.get_the_title().'</h3>'; | |
| } | |
| remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); | |
| add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10 ); | |
| // ---------------------------------------------------------------------------------- | |
| // @Produt details page | |
| remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); | |
| function print_hr(){ | |
| echo '<hr />'; | |
| } | |
| function woo_social_share(){ | |
| echo do_shortcode( '[woocommerce_social_media_share_buttons]' ); | |
| } | |
| add_action( 'woocommerce_single_product_summary', 'print_hr', 5 ); | |
| remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 ); | |
| add_action( 'woocommerce_single_product_summary', 'print_hr', 10 ); | |
| add_action( 'woocommerce_single_product_summary', 'woo_social_share', 10 ); | |
| add_action( 'woocommerce_single_product_summary', 'print_hr', 11 ); | |
| add_action( 'woocommerce_single_product_summary', 'print_hr', 20 ); | |
| remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
| add_action( 'woocommerce_single_product_summary', 'print_hr', 50 ); | |
| remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 ); | |
| add_action( 'woocommerce_before_variations_form', 'woocommerce_template_single_rating', 5 ); | |
| add_action( 'woocommerce_before_variations_form', 'print_hr', 5 ); | |
| add_action( 'woocommerce_before_single_variation', 'print_hr', 5 ); | |
| add_action( 'woocommerce_product_meta_end', 'print_hr', 5 ); | |
| add_action( 'woocommerce_product_meta_end', 'print_hr', 5 ); | |
| add_action( 'woocommerce_product_meta_end', 'woocommerce_template_single_add_to_cart', 5 ); | |
| // @quantity input + & - event script | |
| function quntity_input_script_to_footer(){ | |
| if( ! is_admin() ) { ?> | |
| <script> | |
| jQuery(document).ready(function($){ | |
| $(document).on('click', '.plus', function(e) { // replace '.quantity' with document (without single quote) | |
| $input = $(this).prev('input.qty'); | |
| var val = parseInt($input.val()); | |
| var step = $input.attr('step'); | |
| step = 'undefined' !== typeof(step) ? parseInt(step) : 1; | |
| $input.val( val + step ).change(); | |
| }); | |
| $(document).on('click', '.minus', // replace '.quantity' with document (without single quote) | |
| function(e) { | |
| $input = $(this).next('input.qty'); | |
| var val = parseInt($input.val()); | |
| var step = $input.attr('step'); | |
| step = 'undefined' !== typeof(step) ? parseInt(step) : 1; | |
| if (val > 0) { | |
| $input.val( val - step ).change(); | |
| } | |
| }); | |
| }); | |
| </script> | |
| <?php } | |
| } | |
| add_action( 'wp_footer', 'quntity_input_script_to_footer' ); | |
| add_filter('loop_shop_columns', 'loop_columns'); | |
| if (!function_exists('loop_columns')) { | |
| function loop_columns() { | |
| return 4; // 3 products per row | |
| } | |
| } | |
| ?> |
in woocommerce/global/quantity-input.php
inside else loop
```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add_action( 'wp_footer', 'masonic_woocommerce_quntity_field_script' );
public function masonic_woocommerce_quntity_field_script()
{
if( ! is_admin() ) { ?>
<script>