Please refer to TemplateMonster Support for any issues surrounding TemplateMonster/TemplateTuning Themes – thanks, Jigoshop Team

Shortcode for Jigoshop featured products in particular product category

ivica's Avatar

ivica

11 Mar, 2012 06:11 PM

In Jigishop exists 2 shortcodes:

FEATURED PRODUCTS
[featured_products per_page="12" columns="4" pagination="yes"] - Works exactly the same as recent products but displays products which have been set as “featured”. CATEGORY
[jigoshop_category slug="category-name" per_page="8" columns="4" pagination="yes"] - Works the same way as recent products shortcode, but instead it displays the category you input for slug.

Is it possible to combine these 2 shortcodes in new shortcode: featured product in category? Why? In order to be able to put on particular page for one product (e.g green tee product) ALL featured products from ONE category, something like below:
[jigoshop_category slug="category-name" featured_products per_page="12" columns="4" pagination="yes"]

Is this easily doable or it is problematic? This new shortcode would enhance (considerably) our webpage(s). Thx!

  1. 2 Posted by dyu on 23 Mar, 2012 04:50 PM

    i want a short code for popular products

  2. Support Staff 3 Posted by ivica on 23 Mar, 2012 06:18 PM

    ivica's Avatar
  3. 4 Posted by shashi on 18 Apr, 2012 07:15 AM

    Can you guide me how to create shortcode for featured product for a particular a category. Like
    [jigoshop_category slug="category-name" featured_products per_page="12" columns="4" pagination="yes"] thanks

  4. 5 Posted by Kati on 09 May, 2012 06:22 PM

    I want to place featured products on my homepage. I followed the instructions about how to solve this but no seccess. Where do I have to insert the necessary shortcode? Thanks

  5. Support Staff 6 Posted by ivica on 09 May, 2012 07:32 PM

    ivica's Avatar

    You put shortcodes at your pages (or posts, if they are meant to be put on
    posts)...

  6. 7 Posted by Shashi Bhushan on 10 May, 2012 10:10 AM

    Hi ivica,

    I tried to figure out the solution and it is working for me.

    You will find the code at my personal blog at http://shashibhushan.in/shortcode-for-jigoshop-featured-products-in...

    If you have any issue please let me know.

    Thanks

  7. 8 Posted by timc on 26 Jun, 2013 04:55 AM

    Is this shortcode possible yet?

    I'd like to show featured products from a specific category. There doesn't seem to be a solution to this yet. It would be a very useful feature.

    Alternatively, I'd like to show random products from a specific category, but I don't think this is possible either.

    Any advice offer would be much appreciated. Thank you!

    Tim

  8. 9 Posted by Shashi Bhushan on 02 Jul, 2013 04:00 PM

    In Jigishop exists 2 shortcodes:

    FEATURED PRODUCTS : [featured_products per_page="12" columns="4" pagination="yes"] Works exactly the same as recent products but displays products which have been set as featured.
    CATEGORY PRODUCTS : [jigoshop_category slug="category-name" per_page="8" columns="4" pagination="yes"] Works the same way as recent products shortcode, but instead it displays the category you input for slug.

    I have seen many people is looking for combining these two shortcodes together.
    I tried my hands and find out the solution. This will display the featured product from a particular category based on the slug provided.
    Please go to your Plugin folder and open the file jigoshop >> jigoshop_shortcodes.php and paste the following line of code in the file :
    ################################## Featured Product By Category Short Code By : SHASHI BHUSHAN ######################

    function jigoshop_featured_products_cat( $atts ) {

    global $columns, $per_page, $paged;

    extract( shortcode_atts( array(
    'slug' => '',
    'per_page' => get_option('jigoshop_catalog_per_page'),
    'columns' => get_option('jigoshop_catalog_columns'),
    'orderby' => get_option('jigoshop_catalog_sort_orderby'),
    'order' => get_option('jigoshop_catalog_sort_direction'),
    'pagination'=> false
    ), $atts));

    $args = array(
    'post_type' => 'product',
    'post_status' => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page' => $per_page,
    'orderby' => $orderby,
    'order' => $order,
    'paged' => $paged,
    'meta_query' => array(
    array(
    'key' => 'visibility',
    'value' => array( 'catalog', 'visible' ),
    'compare' => 'IN'
    ),
    array(
    'key' => 'featured',
    'value' => true
    ),

    ),
    'tax_query' => array(
    array(
    'taxonomy' => 'product_cat',
    'field' => 'slug',
    'terms' => esc_attr( $slug ),
    'operator' => 'IN'
    )
    )
    );

    query_posts( $args );
    ob_start();
    jigoshop_get_template_part( 'loop', 'shop' );
    if($pagination) do_action('jigoshop_pagination');
    wp_reset_query();
    return ob_get_clean();
    }

    Also add the following lines at bottom of the page :
    add_shortcode('featured_products_cat', 'jigoshop_featured_products_cat');

    Now you can call this short code in your pages or in the widget. For using this shortcode you have to use this code in your pages:
    [featured_products_cat slug="category-slug" featured_products_cat per_page="3" columns="1" pagination="no"]

  9. 10 Posted by timc on 04 Jul, 2013 10:49 PM

    Thanks for the code Shashi. I will definitely give this a try. Much appreciated.

    Cheers
    Tim

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.