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

echo product id and product_item_key in cart [closed]

Techno Deviser, probably by mistake, in the foreach loop set value to $fragments[‘div.header-cart-count’] instead append it. Try this modification: function iconic_cart_count_fragments( $fragments ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $fragments[‘div.header-cart-count’] .= ‘<div class=”header-cart-count”>’ .$cart_item_key.'<br><br>’. $cart_item[‘product_id’]. ‘</div>’; } return $fragments; } Or: function iconic_cart_count_fragments( $fragments ) { $cart = WC()->cart->get_cart(); if (!empty($cart)) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)