Okay
  Public Ticket #2656854
Pricing table on shop page
Closed

Comments

  •  1
    Darren started the conversation

    Hi,

    Is it possible to display the tiered pricing on the shop page underneath each product as well as on the single product page?


    Thanks for your time
    Darren

  •  2,218
    WebWizards replied

    Hi Darren,

    I think that may look a bit too crowded on the shop page, but I suppose it depends on your theme and how products are displayed.


    You can do that if you are open to modifying the plugin code.


    To do that modification:

    In class-b2bking-public.php you can find the following code (approx. lines 370-390). 

    These are the tables for simple products and for variable products.

    // Show table for tiered prices in product / variation page 
    add_action('woocommerce_after_add_to_cart_button', array($this,'b2bking_show_tiered_pricing_table'));
    add_filter('woocommerce_available_variation', array($this,'b2bking_show_tiered_pricing_table_variation'), 10, 3 );
    


    You can also add the following line of code there to also display the tables in the shop page under the item:

    add_action('woocommerce_after_shop_loop_item', array($this,'b2bking_show_tiered_pricing_table'));
    


    The result looks like this with Storefront theme: (but it might differ with different themes)

    3675046100.png


    The above works for simple products, but it will be difficult to make it work for variable products - each variation can have its own table, so I'm not sure how that would work on the shop page.


    Kind Regards,

    Stefan

  •  15
    Darren Robinson replied

    This works great but How can I make it so the pricing table only shows on the shop page to WP user role reps only?


    Thank you for your time

    Darren

  •  2,218
    WebWizards replied

    Hi Darren,

    You can do that by adding the following code snippet to the site:

    $user = get_current_user();
    if (is_object($user)){
        $user_roles = $user->roles;
    } else {
        $user_roles = array();
    }
    if ( in_array( 'reps', $user_roles)) {
        // the code here only applies to reps
        global $b2bking_public;
        add_action('woocommerce_after_shop_loop_item', array($b2bking_public,'b2bking_show_tiered_pricing_table'));
    }
    

    I do not know what you are using for reps. I wrote 'reps' in the above code snippet, but I don't know if that's the actual name of the role.

    If you are using our SalesKing plugin let me know, I can give more details.


    Kind regards,

    Stefan