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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Add description to menu items | |
add_filter( 'walker_nav_menu_start_el', 'wpstudio_add_description', 10, 2 ); | |
function wpstudio_add_description( $item_output, $item ) { | |
$description = $item->post_content; | |
if (' ' !== $description ) { | |
return preg_replace( '/(<a.*)</', '$1' . '<span class="menu-description">' . $description . '</span><', $item_output) ; |
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Remove default sidebar, add shop sidebar | |
add_action( 'genesis_before', 'wpstudio_add_woo_sidebar', 20 ); | |
function wpstudio_add_woo_sidebar() { | |
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
if( is_woocommerce() ) { | |
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); |
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 WooCommerce cart to primary navigation Genesis | |
* @author Frank Schrijvers | |
* @link https://www.wpstud.io/add-woocommerce-cart-to-genesis-navigation/ | |
*/ | |
if ( class_exists( 'WooCommerce' ) ) { | |
add_action( 'genesis_header_right', 'wpstudio_add_cart' ); | |
function wpstudio_add_cart() { | |
echo '<div class="mini-cart">'; | |
echo '<a href="' . WC()->cart->get_cart_url() .'"title="View your shopping cart">'. WC()->cart->get_cart_total(). '</a>'; |
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Change add to cart button text single product page | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wps_custom_cart_button_text' ); | |
function wps_custom_cart_button_text() { | |
return __( 'Buy Product', 'your_theme_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
<?php | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Change add to cart button text per category | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wps_custom_cart_button_text' ); | |
function wps_custom_cart_button_text() { | |
global $product; | |
$terms = get_the_terms( $product->ID, 'product_cat' ); | |
foreach ($terms as $term) { |
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Change add to cart button text per category archive pages | |
add_filter( 'woocommerce_product_add_to_cart_text', 'wps_archive_custom_cart_button_text' ); | |
function wps_archive_custom_cart_button_text() { | |
global $product; | |
$terms = get_the_terms( $product->ID, 'product_cat' ); | |
foreach ($terms as $term) { |
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wps_custom_cart_button_text' ); | |
/** | |
* Set product button text to productname | |
*/ | |
function wps_custom_cart_button_text() { | |
global $product; |
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 gallery thumbs to woocommerce shop page | |
add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs', 5); | |
function wps_add_extra_product_thumbs() { | |
if ( is_shop() ) { | |
global $product; | |
$attachment_ids = $product->get_gallery_attachment_ids(); |
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
** | |
* woocommerce_package_rates is a 2.1+ hook | |
*/ | |
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 ); | |
/** | |
* Hide shipping rates when free shipping is available | |
* | |
* @param array $rates Array of rates found for the package | |
* @param array $package The package array/object being shipped |
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Update the order meta with field value | |
add_action('woocommerce_checkout_update_order_meta', 'wps_select_checkout_field_update_order_meta'); | |
function wps_select_checkout_field_update_order_meta( $order_id ) { | |
if ($_POST['daypart']) update_post_meta( $order_id, 'daypart', esc_attr($_POST['daypart'])); | |
} |
NewerOlder