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
/** | |
* Hides checkout fields based on the products in the cart | |
* | |
* @param array $fields | |
* @return array | |
*/ | |
function conditional_checkout_fields_products( $fields ) { | |
$cart = WC()->cart->get_cart(); | |
$has_tag = true; |
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
// Enable WP_DEBUG mode | |
define('WP_DEBUG', true); | |
// Enable Debug logging to the /wp-content/debug.log file | |
define('WP_DEBUG_LOG', true); |
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 customize_grouped_product_title( $tilte, $product ) { | |
if ( $product->get_parent() > 0 ) { | |
$title = get_the_title( $product->id ); | |
} | |
return $title; | |
} |
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 temporary_fix_product_search( $where ) { | |
global $pagenow, $wpdb, $wp; | |
if ( 'edit.php' != $pagenow || ! is_search() || ! isset( $wp->query_vars['s'] ) || 'product' != $wp->query_vars['post_type'] ) { | |
return $where; | |
} | |
$where = str_replace( "post_type = ' '", "post_type = 'product'", $where ); | |
return $where; | |
} |
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_filter( 'woocommerce_product_thumbnails_columns', create_function( '', 'return 4;' ) ); |
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
This is not a bug, it's the expected behavior. There is a cut off at **20 variations**. More explanation on this is done here: https://woocommerce.wordpress.com/2015/07/13/improving-the-variations-interface-in-2-4/. | |
In the frontend, if a variable product has more than 20 variations, the data will be loaded via AJAX rather than handled inline. | |
It is possible to change this quantity using the `woocommerce_ajax_variation_threshold` filter. After 20 by default, it starts checking with the database after the selections are made. | |
Add this code in the file `functions.php` located in your theme folder in `wp-content/themes/your-theme-name/`: | |
https://gist.github.com/SiR-DanieL/2e178ed6f0d9a58e9959 | |
If you want, you can also edit the file directly from the dashboard in WordPress. To do so, navigate to **Appearance > Editor** and find the file **Theme Functions (functions.php)** in the list on the right of the page, like in this screenshot: |
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 | |
if ( is_front_page() && is_home() ) { | |
// Default homepage | |
} elseif ( is_front_page() ) { | |
// static homepage | |
} elseif ( is_home() ) { | |
// blog page | |
} else { | |
//everything else | |
} |
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 | |
if ( ! is_admin() ) { | |
wp_enqueue_script( 'google-analytics', get_template_directory_uri() . '/my-ga.js' ); | |
} |
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 print_shop_banner( $content ) { | |
if ( is_shop() ) { | |
$content .= '<img src="http://domain.com/wp-content/uploads/myawesomebanner.png" />'; | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'print_shop_banner' ); |
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
if ( is_product() ) { | |
echo 'Must have!'; | |
} else if ( is_product_tag( array( 'tag1', 'tag2' ) ) ) { | |
echo 'Check these awesome products tagged "tag1" and "tag2"!'; | |
} else if ( is_product_category() ) { | |
echo 'Don\'t you like the products in this category?'; | |
} |