• Resolved hpiiph102

    (@hpiiph102)


    Good day,

    I just want to ask if it is possible to include short description on every product and make it categorized.

    E.G.

    Condiments(Category)
    soy sauce 1 litter per bottle (short description)
    vinegar 1 litter per bottle (short description)

    Your quick response will highly appreciate. Thank you.

    MJ

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello MJ,
    Printing the products by category is quite difficult, you’d have to create a custom template and then loop through all the products to categorize them and then print them per category. Adding the Category and short description is easier:
    Displaying product description
    Print a list of categories under each product name

    If you prefer a solution that doesn’t require meddling with custom code snippets, you can do both these things with our Premium Templates extension too (as you can see in the screenshot, you can choose to put the short description below the product or in a separate column):

    Hope that helps!

    Thread Starter hpiiph102

    (@hpiiph102)

    Hi Ewout,

    Thank you for your quick response.

    How about the categorized product by category? Is that possible ?

    Like this,

    PRODUCTS QUANTITY PRICE
    Condiments(Category)
    soy sauce 1 ?1,000.00
    vinegar 1 ?1,000.00

    Thanks,
    MJ

    Plugin Contributor Ewout

    (@pomegranate)

    Technically that’s possible, but as I wrote in my previous response, this will require some custom coding:

    Printing the products by category is quite difficult, you’d have to create a custom template and then loop through all the products to categorize them and then print them per category

    Thread Starter hpiiph102

    (@hpiiph102)

    Hi Ewout,

    How about, sort the product by category?

    example

    Product 1 Condiments
    Product 2 Condiments
    Product 3 Condiments
    Product 4 Vegetables
    Product 5 Vegetables

    Thanks,
    MJ

    Plugin Contributor kluver

    (@kluver)

    Hi @hpiiph102,

    You can use the following code snippet to achieve that:

    // Sort items on the invoice alphabetically by category
    add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_sort_items_by_category', 10, 3 );
    function wpo_wcpdf_sort_items_by_category ( $items, $order, $document_type ) {
    	if( $document_type == 'invoice' ) {
    		usort($items, function ($a, $b) {
    			$categories_a = strip_tags( wc_get_product_category_list( $a['product_id'] ) );
    			$categories_b = strip_tags( wc_get_product_category_list( $b['product_id'] ) );
    			return strcmp($categories_a, $categories_b);
    		});
    	}
    	return $items;
    }

    This code snippet should be placed in the functions.php of your child theme. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Short Description and Categorize order’ is closed to new replies.