Grid View - Add to Cart & View Details

ScrapsArt.com

In the grid view it currently shows the option of view product and then add to cart once you are on the product page.

How to have an add to cart button alongside the view details on the grid view?

  • Rupok

    Hi Erum,

    Thanks for asking. Normally MarketPress shows "Add to Cart" button or "Buy Now" button in Products page. But on your site, it's showing the "View Product" button. Did you do any customization in this plugin or did you customize the MarketPress product page template on your site?

    Moreover, the cart functionality on your site is not regular MarketPress way. Normally, a mini cart is shown and then you are taken to the cart page where you can modify your order. But on your site, everything is done on the sidebar. So I believe, there is high amount of customization on your site.

    Can you please tell us what have been done so far so we can understand how you should be able to show the Add to Cart button on your product images?

    We have a complete blog article on theming MarktePress pages, here: https://premium.wpmudev.org/blog/the-easy-guide-to-theming-marketpress/

    According to this article, you should be able to show the but button with the following code:
    mp_buy_button(true, 'single');

    Can you please go through that article and try the methods shown there?

    I believe, this will help. Please let us know if you have any confusion or any further query. We will be glad to help.

    Have a nice day. Cheers!
    Rupok

  • Nithin

    Hi Erum,

    You are using the following shortcode to view the products in Grid view:
    [mpdg id="255"]

    This shortcode is related to MP Mojo plugin, and not MarketPress, and the plugin shortcode defines the View Product button, and the structure for grids. Since it's a premium plugin, I'm not sure how that shortcode behaves, or whether there is any such hooks to work upon.

    It's pretty tough to suggest without checking the MP Mojo plugin code. The function to add "Add to Cart" button would be:
    mp_buy_button();

    You can share the code related to my_buy_button function to the plugin developer, so that they would be able to incorporate it according to their plugins shortcode:

    function mp_buy_button( $echo = true, $context = 'list', $product_id = null ) {
    		//_deprecated_function( 'mp_buy_button', '3.0', 'MP_Product::buy_button' );
    
    		$product = new MP_Product( $product_id );
    		if ( ! $product->exists() ) {
    			return;
    		}
    
    		$button = $product->buy_button( false, $context, array(), true, true );
    
    		if ( $echo ) {
    			echo $button;
    		} else {
    			return $button;
    		}
    	}

    Please do let us know how that goes, so that we could give a closer look, if needed. Have a nice day.

    Best Regards,
    Nithin