Woocommerce include custom stylesheet after woocommerce styling [closed]

wp_enqueue_style supports dependencies. So, if you make the WooCommerce style a dependency for your new stylesheet then your stylesheet will always load after the WooCommerce stylesheet. Something like this ought to work, but it is untested: function enqueue_style_after_wc(){ $deps = class_exists( ‘WooCommerce’ ) ? array( ‘woocommerce-layout’, ‘woocommerce-smallscreen’, ‘woocommerce-general’ ) : array(); wp_enqueue_style( ‘my-style’, ‘my-style.css’, $deps, … Read more

Add .html to Woocommerce permalinks [closed]

This is the simplest way to add .html, which involves overriding the default permastructure: function wpse_178112_permastruct_html( $post_type, $args ) { if ( $post_type === ‘product’ ) add_permastruct( $post_type, “{$args->rewrite[‘slug’]}/%$post_type%.html”, $args->rewrite ); } add_action( ‘registered_post_type’, ‘wpse_178112_permastruct_html’, 10, 2 ); http://codex.wordpress.org/Function_Reference/add_permastruct For categories: function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) { if ( $taxonomy === ‘product_cat’ ) add_permastruct( … Read more

How to get product count with respect to categories in WooComerce

You just need to add $cat->count to get the count of all products in that category. Hope this helps you out. $args = array( ‘number’ => $number, ‘orderby’ => $orderby, ‘order’ => $order, ‘hide_empty’ => $hide_empty, ‘include’ => $ids ); $product_categories = get_terms( ‘product_cat’, $args ); foreach( $product_categories as $cat ) { echo $cat->name.’ (‘.$cat->count.’)’; … Read more

How do I get the latest note on the order at woocommerce? [closed]

The order notes are saved as post comments, so you can use the WordPress function get_comments() to get the last note: $args = array( ‘post_id’ => $order_id, ‘orderby’ => ‘comment_ID’, ‘order’ => ‘DESC’, ‘approve’ => ‘approve’, ‘type’ => ‘order_note’, ‘number’ => 1 ); remove_filter( ‘comments_clauses’, array( ‘WC_Comments’, ‘exclude_order_comments’ ), 10, 1 ); $notes = get_comments( … Read more

Redirect the single product page link to the shop page

You can try using template_redirect action hook to check if the current page is product page and after that, you can redirect the user to your shop page. Paste this code into your functions.php add_action(‘template_redirect’,’custom_shop_page_redirect’); function custom_shop_page_redirect(){ if (class_exists(‘WooCommerce’)){ if(is_product()){ wp_redirect(home_url(‘/shop/’)); exit(); } } return; } I have not tested it, but hope it will … Read more