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 | |
| add_filter( 'woocommerce_variation_is_active', 'disable_out_of_stock_variations', 10, 2 ); | |
| function disable_out_of_stock_variations( $active, $variation ) { | |
| if( ! $variation->is_in_stock() ) { | |
| return false; | |
| } | |
| return $active; | |
| } |
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 | |
| add_filter('woocommerce_show_variation_price', function() {return true;}); | |
| ?> |
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 | |
| // Add this function to any hook listed here - https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ | |
| function product_variation_values() { | |
| global $product; | |
| if ( $product->is_type( 'variable' ) ) { | |
| $variations = $product->get_available_variations(); | |
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 | |
| // You can add this function to any hook listed here - https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ | |
| function product_attributes() { | |
| global $product; | |
| // GET SPECIFIC ATTRIBUTE | |
| $attribute = $product->get_attribute( 'pa_attribute' ); | |
| $specificAttribute = $product->get_attribute( 'pa_specific-attribute' ); |
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 | |
| // ARCHIVE | |
| add_filter('woocommerce_product_add_to_cart_text', 'custom_archive_cart_button_text'); | |
| function custom_archive_cart_button_text() { | |
| return __('Purchase', 'woocommerce'); | |
| } | |
| // SINGLE PAGE | |
| add_filter('woocommerce_product_single_add_to_cart_text', 'custom_single_cart_button_text'); |
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
| add_action( 'woocommerce_before_add_to_cart_quantity', 'display_quantity_minus' ); | |
| function display_quantity_minus() { | |
| echo '<div class="quantity-wrapper"><span>Qty</span><button type="button" class="minus" >-</button>'; | |
| } | |
| add_action( 'woocommerce_after_add_to_cart_quantity', 'display_quantity_plus' ); | |
| function display_quantity_plus() { | |
| echo '<button type="button" class="plus" >+</button></div>'; | |
| } |
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 | |
| // THIS SNIPPET ADDS CUSTOM FIELD 'price_per_unit' TO THE OPTION LABEL. | |
| add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'custom_dropdown_args_label', 10, 2); | |
| function custom_dropdown_args_label( $html, $args ) { | |
| $options = $args['options']; | |
| $product = $args['product']; | |
| $attribute = $args['attribute']; | |
| $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute ); |
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 | |
| // You can add this function to any hook listed here - https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ | |
| function woocommerce_total_product_price() { | |
| global $woocommerce, $product; | |
| if( $product->is_type( 'simple' ) ){ | |
| echo '<div class="total-cost-wrapper">Total Cost <span class="dynamic-price">' . get_woocommerce_currency_symbol() . $product->get_price() . '</span></div>'; | |
| ?> |
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 | |
| // You can add this function to any hook listed here - https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ | |
| function custom_wc_template_single_price() { | |
| global $product; | |
| if ( $product->is_type('variable') ): | |
| // Main Price |