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>'; | |
} | |
} | |
?> |
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
/* | |
* 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
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
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
/* | |
* 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
// original source http://stackoverflow.com/a/35072168 | |
function itl_is_product_the_same_cat( $valid, $product_id, $quantity ) { | |
global $woocommerce; | |
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) { | |
$_product = $values['data']; | |
$terms = get_the_terms( $_product->id, 'product_cat' ); | |
$target_terms = get_the_terms( $product_id, 'product_cat' ); // get the current items |
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
// in line 61 insert your piwik url | |
// source code: wordpress.org/plugins/woocommerce-piwik-integration/ | |
/* Get encoded categories by product. | |
=========================================================================== */ | |
function getEncodedCategoriesByProduct( $product ) { | |
$categories = get_the_terms( $product->get_id(), 'product_cat' ); | |
if ( ! $categories ) { | |
$categories = array(); |
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
// Let’s presume we have a ‘product’ post type, with a ‘names’ taxonomy. | |
/* The posts_orderby filter. | |
=========================================================================== */ | |
function itl_edit_posts_orderby( $orderby_statement, $wp_query ) { | |
if ( isset( $wp_query->query['orderby'] ) && 'include' == $wp_query->query['orderby'] ) { | |
$include = implode( ',', array_map( 'absint', $wp_query->query['include'] ) ); | |
$orderby_statement = "FIELD( term_taxonomy_id, $include )"; | |
} |
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 Custom Fee to Woocommerce Cart for Physical Products. | |
=========================================================================== */ | |
function itl_woocommerce_custom_fee() { | |
global $woocommerce; | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { | |
return; | |
} | |
$is_physical = false; |
OlderNewer