Remove related products
0 1 2 3 4 5 | function jma_remove_related_products( $args ) { return array(); } add_filter('woocommerce_related_products_args','jma_remove_related_products', 10); |
Redirect ‘add to cart’ button
0 1 2 3 4 5 6 7 | function jma_redirect_add_to_cart() { global $woocommerce; $checkout_url = $woocommerce->cart->get_checkout_url();//get_cart_url(); for cart return $checkout_url; } add_filter ('add_to_cart_redirect', 'jma_redirect_add_to_cart'); |
Redirect ‘back to shop’ button
0 1 2 3 4 5 | function jma_return_to_shop_redirect() { return get_permalink(682); } add_filter( 'woocommerce_return_to_shop_redirect', 'jma_return_to_shop_redirect' ); |
Turn off Themeblvd Woo Images (re-enable woo image size options)
0 1 2 | add_filter('themeblvd_woocommerce_images', '__return_false'); |
Add content to customer emails
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | Function jma_email_before_order_table($order, $sent_to_admin){ $items = $order->get_items(); foreach($items as $item){ $jma_item_list[] = $item['item_meta']['_product_id'][0];//create an array lising item ids in this woocommerce order } if(array_intersect(get_pro_cat_ids('minisites'), $jma_item_list)){/* 21,199 is minisite purchase 80*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your MiniSite Construction Form Instructions</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(169) ?>"><?php echo get_the_title( 169 ); ?></a> </div> <?php } if(in_array(101, $jma_item_list)){/* 101 dns help addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your DNS Help Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(88) ?>"><?php echo get_the_title( 88 ); ?></a> </div> <?php } if(in_array(99, $jma_item_list)){/* 99 header design addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your Header Design Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(170) ?>"><?php echo get_the_title( 170 ); ?></a> </div> <?php } if(in_array(97, $jma_item_list)){/* 97 newsletter popup addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your Popup Newsletter Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(171) ?>"><?php echo get_the_title( 171 ); ?></a> </div> <?php } ?> <?php } add_action('woocommerce_email_before_order_table', 'jma_email_before_order_table', 10, 2); |
helper for above function
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* helper - * function get_pro_cat_ids * returns an array of ids for products in category $catslug * @param string $catslug slug of the category in question * * return array of product id (or false of failure) * * */ function get_pro_cat_ids($catslug){ $args = array( 'post_type' => 'product', 'product_cat' => $catslug, 'posts_per_page' => -1, ); $minisites = get_posts( $args ); if(count($minisites)){ foreach($minisites as $minisite){ $return[] = $minisite->ID; } }else{ $return[] = 'empty'; } return $return; } |
Remove/edit tabs (user new callback to edit tab content)
0 1 2 3 4 5 6 7 8 9 10 11 12 | function jma_remove_woo_product_tabs( $tabs ) { echo '<pre>'; print_r($tabs);echo '</pre>'; unset( $tabs['description'] ); // Remove the description tab unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab return $tabs; } function jma_manage_woo_content(){ add_filter( 'woocommerce_product_tabs', 'jma_remove_woo_product_tabs', 98 ); } add_action('template_redirect', 'jma_manage_woo_content'); |
print_r on $tabs array
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Array ( [description] => Array ( [title] => Description [priority] => 10 [callback] => woocommerce_product_description_tab ) [reviews] => Array ( [title] => Reviews (1) [priority] => 30 [callback] => comments_template ) ) |
Hide Empty Cart
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function jma_woocommerce_mods() { // Avoid errors, if you ever disable WooCommerce if ( ! themeblvd_installed('woocommerce') ) { return; } // Get the single instance of our object $tbwc = Theme_Blvd_Compat_WooCommerce::get_instance(); // Remove framework modification of hypothetical woocommerce_foo action hook if(WC()->cart->get_cart_contents_count() < 1){ remove_action( 'themeblvd_do_cart', '__return_true' ); remove_action( 'themeblvd_floating_cart', array($tbwc, 'cart') ); remove_action( 'themeblvd_after', array($tbwc, 'add_cart') ); } } add_action( 'template_redirect', 'jma_woocommerce_mods', 11 ); |