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( 'body_class', 'add_product_type_class' ); | |
function add_product_type_class( $classes ) { | |
if ( is_product() ){ | |
global $product; | |
$productID = $product->get_id(); | |
// BASED ON PRODUCT TYPE | |
$productType = get_the_terms( $productID, 'product_type')[0]->slug; |
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 | |
global $product; | |
$productID = $product->get_id(); | |
// CHECK IF PRODUCT BELONGS TO CATEGORY | |
if ( has_term( 'term', 'product_cat', $productID ) ) { //term can be category name, id, slug or an array of each to check for | |
// Do something | |
} |
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_action( 'wp_enqueue_scripts', 'remove_woo_lightbox', 99 ); | |
function remove_woo_lightbox() { | |
if ( is_product() ) { | |
wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); | |
wp_dequeue_script( 'prettyPhoto' ); | |
wp_dequeue_script( 'prettyPhoto-init' ); | |
} | |
} |
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_get_price_html', 'custom_price_display', 10, 2 ); | |
function custom_price_display( $price, $product ) { | |
// CHANGE FOR ALL PRODUCTS | |
$price .= ' for each item'; | |
// FOR SPECIFIC PRODUCT | |
if ( $product->get_id() == 15 ) { // Replace 15 with your product ID |
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 |
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 | |
// 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 ); |
OlderNewer