• Resolved Haja

    (@hajakutbudeen)


    Hello there,

    I am using Woocommerce shortcodes to display products into my site for example:

    [products ids= ‘111,222,334,211’ columns=’3′ limit=’12’ pagination=’yes’]

    there is more than 4000 products we have in our site. i pull those ids pass that into ids parameter like this.

    Ex:
    $arr = array(111,222,334,211,312,534,345,113,555,333,865,884,765) //etc
    $str = implode(‘,’,$arr);
    [products ids= ‘$str’ columns=’3′ limit=’12’ pagination=’yes’]

    Its not displayed products, its shown error ‘No products were found matching your selection’

    Please advise product ids has any limitation ? or it there any rule i need to follow to display product via woocommerce shorcode ?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello there,

    Sorry to hear about this.

    Please check this documentation for a reference.

    I hope this leads you in the right direction.

    Thread Starter Haja

    (@hajakutbudeen)

    Hi @ihereira,

    Kindly please reply, It’s that true ? woo-commerce short code: [products ids=”]
    will accept only 3161 ids ? because i load 3808 ids into that, it not work when i remove 647 ids from that then works.! Please advise.

    Mirko P.

    (@rainfallnixfig)

    Hello @hajakutbudeen,

    when i remove 647 ids from that then works

    That’s strange! There should not be a limitation unless is something related to your theme. Make sure to use pagination="true", switch the theme to Storefront, and check if it works.

    Also, for the shortcode to work correctly, you need to use straight quotation marks:

    https://woocommerce.com/document/woocommerce-shortcodes/#section-22

    Thanks.

    Thread Starter Haja

    (@hajakutbudeen)

    Hello @rainfallnixfig,

    Thanks for your replay, your information really useful for me. I noted that.

    In my case what i understand i think i reach string limit, i am not sure please advise if i am wrong.

    When i copied all product ids from database paste into products ids param like this:

    [products ids= “5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648,5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659” columns=”3″ limit=”12″ pagination=”yes”]

    i copied all ids into MS word and checked the character count i noticed its 19000 characters total.
    This same code work if i remove some ids (when characters around 15000)

    Hi @hajakutbudeen

    i copied all ids into MS word and checked the character count i noticed its 19000 characters total. This same code work if i remove some ids (when characters around 15000)

    19000 characters is quite long. You may want to consider an alternative way to display those products, such as put the applicable products in a category and use shortcode like [products category='category-1' columns='3' limit='12' pagination='true'].

    If you need to bulk edit products, you can use the built-in Product CSV Importer and Exporter: https://woocommerce.com/document/product-csv-importer-exporter/

    • This reply was modified 4 years, 2 months ago by MayKato.
    Thread Starter Haja

    (@hajakutbudeen)

    Hello @maykato,

    Thanks for your replay. I can’t create category because i load products based on countries.

    My current category for ex:

    – Grocery
    – Food
    – Electronics
    – Mobiles
    – Home Appliances
    – Offers`

    If i create country based category it will be like this. and it’s hard to manage.

    – USA
    – Grocery
    – Food
    – Electronics
    – Mobiles
    – Home Appliances
    – Offers`
    – UK
    – Grocery
    – Food
    – Electronics
    – Mobiles
    – Home Appliances
    – Offers`

    Is there any alternative option can suggest ? because currently we have 4000 products if we expand to another country it will double or more

    • This reply was modified 4 years, 2 months ago by Haja.

    Hi @hajakutbudeen

    You mentioned you are already having categories – Grocery, Food, Electronics, Mobiles, Home Appliances, Offers.

    Please try using the following shortcode category-wise and let us know if that helps.

    For grocery:
    [products category='grocery' columns='3' limit='18' pagination='true']

    For food:
    [products category='food' columns='3' limit='18' pagination='true']

    etc.

    Thread Starter Haja

    (@hajakutbudeen)

    Hello @margaretwporg,

    We have page:
    – Shop page
    – category1 page (Ex: Grocery)
    – category2 page (Ex: Electronics)
    – category3 page (Ex: Mobiles)

    We have product:

    products from USA:
    usa_prd_1, usa_prd_2, usa_prd_3 … usa_prd_2000

    products from UK:
    uk_prd_1, uk_prd_2, uk_prd_3 … uk_prd_2000

    Shop currenctly displayed all USA & UK products, thats why we go with shortcode

    [products ids=’$ids_list’ columns=’3′ limit=’12’ pagination=’true’]

    In $ids_list we store only ids based on geo location using SQL Query.

    category will not work for us. because we don’t have country based category. its hard to maintain.

    I’ve noticed:

    When we pass WC_Shortcodes::products it will convert code pass into WP_Query like this ($ids area list of ids will add)

    $query = new WP_Query( array (
    				"post_type" => "product",
    				"post_status" => "publish",
    				"ignore_sticky_posts" => true,
    				"no_found_rows" => 0,
    				"orderby" => "price",
    				"order" => "ASC",
    				"posts_per_page" => 12,
    				"meta_query" => [],
    				"tax_query" => array(
    						array( 
    						"taxonomy" => "product_visibility",
    						"field" => "term_taxonomy_id",
    						"terms" => [7,9],
    						"operator" => "NOT IN"
    						),
    					),
    				"post__in" => $ids,
    				"paged" => 0,
    				"prdctfltr_active" => true,
    				"fields" => "ids"
    			) );

    $query->posts will have first 12 product ids which is need to display.
    Ex:

    "posts": [
            342,
            439,
            431,
            453,
        ]

    but when its contain more ids $query->posts return empty
    Ex:
    "posts": []

    I need some tech ppl advise to fix this

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @hajakutbudeen,

    It sounds like you need to seek the assistance of a professional developer to help you with what you need here.

    If you don’t have a go-to developer, we highly recommend contacting one of the services on our customizations page: https://woocommerce.com/customizations/.

    Hopefully, you were able to find a way forward with the issue. I’m going to mark the thread as resolved. Feel free to create a new topic if you need assistance with anything else.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Shortcode doesn’t show products’ is closed to new replies.