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
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 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 | |
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 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 | |
if ( ! is_admin() ) { | |
wp_enqueue_script( 'google-analytics', get_template_directory_uri() . '/my-ga.js' ); | |
} |
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_filter( 'woocommerce_price_html', 'change_price_notice' ); | |
/** | |
* Changes the 'Free!' price notice | |
*/ | |
function change_price_notice() { | |
return 'From $59.00'; | |
} |
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
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 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
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?'; | |
} |
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_filter( 'woocommerce_product_tabs', 'woo_edit_tabs' ); | |
function woo_edit_tabs( $tabs ) { | |
// Adds the new tab | |
$tabs['enquiry_form'] = array( | |
'title' => __( 'Ask a question', 'woocommerce' ), | |
'priority' => 50, | |
'callback' => 'woo_enquiry_form' | |
); |
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_product_options_general_product_data', 'wc_custom_add_custom_fields' ); |
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_product_options_general_product_data', 'wc_custom_add_custom_fields' ); | |
function wc_custom_add_custom_fields() { | |
// Print a custom text field | |
woocommerce_wp_text_input( array( | |
'id' => '_custom_text_field', | |
'label' => 'Custom Text Field', | |
'description' => 'This is a custom field, you can write here anything you want.', | |
'desc_tip' => 'true', | |
'placeholder' => 'Custom 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_process_product_meta', 'wc_custom_save_custom_fields' ); | |
function wc_custom_save_custom_fields( $post_id ) { | |
if ( ! empty( $_POST['_custom_text_field'] ) ) { | |
update_post_meta( $post_id, '_custom_text_field', esc_attr( $_POST['_custom_text_field'] ) ); | |
} | |
} |