This file contains 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 a message to buyers in single product page | |
*/ | |
function itl_display_note_buyers() { | |
global $product; | |
$current_user = wp_get_current_user(); | |
if ( wc_customer_bought_product( $current_user->email, $current_user->ID, $product->id ) ) { | |
_e( 'your message', 'text-domain' ); |
This file contains 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
function itl_add_class_free_products( $price ) { | |
$price = '<span class="amount free-product">' . __( 'Free!', 'woocommerce' ) . '</span>'; | |
return $price; | |
} | |
add_filter( 'woocommerce_variable_free_price_html', 'itl_add_class_free_products' ); | |
add_filter( 'woocommerce_free_price_html', 'itl_add_class_free_products' ); | |
add_filter( 'woocommerce_variation_free_price_html', 'itl_add_class_free_products' ); |
This file contains 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
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
add_action( 'woocommerce_single_product_summary', 'itl_woocommerce_template_single_add_to_cart', 30 ); | |
/* | |
* replace WooCommerce add-to-cart button with download link when product is downloadable & free | |
*/ | |
function itl_woocommerce_template_single_add_to_cart() { | |
global $product; | |
if ( $product->is_downloadable('yes') ) { |
This file contains 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
/* | |
* for see all value use var_dump($product_variations); | |
*/ | |
$product_variations = $product->get_available_variations(); | |
foreach ( $product_variations as $product_variation ) { | |
echo $product_variation['variation_id']; | |
echo $product_variation['display_regular_price']; | |
echo $product_variation['variation_description']; | |
} |
This file contains 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
/* | |
* create in your theme path: your-theme/js/add-to-cart-variation.min.js | |
*/ | |
jQuery(document).ready(function(d){d("form.variations_form").on("click",".reset_variations",function(f){return false}).on("change",".variations input:radio",function(f){$variation_form=d(this).closest("form.variations_form");$variation_form.find("input[name=variation_id]").val("").change();$variation_form.trigger("woocommerce_variation_radio_change").trigger("check_variations",["",false]);d(this).blur();if(d().uniform&&d.isFunction(d.uniform.update)){d.uniform.update()}}).on("focusin",".variations input:radio",function(f){$variation_form=d(this).closest("form.variations_form");$variation_form.trigger("woocommerce_variation_radio_focusin").trigger("check_variations",[d(this).attr("name"),true])}).on("check_variations",function(f,g,r){var l=true;var o=false;var p=false;var q={};var k=d(this);var n=k.find(".reset_variations");k.find(".variations input:radio:checked").each(function(){if(d(this).val().length==0){l=false}else{o=true}if |
This file contains 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; | |
$attributes = $product->get_attributes(); | |
foreach ( $attributes as $attribute ) { | |
$terms = wp_get_post_terms( $product->id, $attribute['name'], 'all' ); | |
foreach ( $terms as $term ) { | |
echo $term->name .'<br>'; | |
} | |
} | |
?> |
NewerOlder