Marketpress: Can I add 'Add to Cart' to a product list or Global product list?

Hi, am trying to add an Add to Cart button to both a Global product list and a site product list. Even though I have Add to Cart ticked in the cms on the Presentation Settings in the Product List Settings section of every site, the lists still show Buy Now.

I notice that in Version 2.5 the changelog shows "Remove add to cart button when in product listing mode and no custom link set".

I almost have global product list working by using the following code in the marketpress-ms.php but the form can't find the post_id value. The Add to Cart button should show when Users are looking at the Global Product List widget on my home page. However, using post_id adds random pages to the cart instead.

$content .= '<form class="mp_buy_form" method="post" action="' . mp_cart_link(false,true) . '">';
$content .= '<input type="hidden" name="product_id" value=" ' . post_id .'" />';
$content .= '<input type="hidden" name="variation" value="0" />';
$content .= '<span class="mp_quantity"><label>' . __('Quantity:', 'mp') . ' <input class="mp_quantity_field" type="text" size="1" name="quantity" value="1" /></label></span> ';
$content .= '<input type="hidden" name="action" value="mp-update-cart" />';
$content .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart »', 'mp') . '" />';
$content .= '</form>';

Can you point me in the right direction with regards to the correct php code to get Add to Cart showing on both Global and Site Product lists? My knowledge of php is pretty basic. (Loops are things I use to tie up my hair).

  • aecnu

    Greetings cowontherun,

    Thank you for this great question!

    I notice that in Version 2.5 the changelog shows "Remove add to cart button when in product listing mode and no custom link set

    I understand this reasoning for sure concerning the no add to cart button when there is no product link because one cannot purchase nothing in this case. But I do not think this is what the issue is at all.

    It is my opinion that the problem is you cannot add an outside product to the cart.

    Here is my reasoning taken directly from the Market Press page --> site admin --> Products --> Store Settings --> General tab and I quote:
    This option turns MarketPress into more of a product listing plugin, disabling shopping carts, checkout, and order management. This is useful if you simply want to list items you can buy in a store somewhere else, optionally linking the "Buy Now" buttons to an external site.

    That kind of says it all for me and if in fact with the cart totally disabled and an "Add to Cart" button but no cart, how would that function?

    Please advise.

    Cheers, Joe

  • cowontherun

    Sorry I'm not making myself clear. I don't want to disable the shopping cart, that would be weird.

    Scenario:
    A user is looking at a list of my products. Each product description is very short with no images so I do not want the User to have to click Buy Now to then go to a second almost empty product description page. Instead, the User should be able to view my product list, click Add to Cart on each product in the list and have that product added to the shopping cart.

    I know there is a simple solution to this. Or If I understood php loops better I'm sure I could get it working. However, I need WPMU's help for this one!

  • aecnu

    Greetings cowontherun,

    We want to help of course :slight_smile:

    The problem is as I indicated above - it is my opinion that you are using the wrong choice i.e. Product Listings Only should be no

    Then you will have access to the shopping cart functions.

    However, maybe I am misinterpreting what you are indicating in the original post which I just read again and still get the same impression.

    Do you have the Products Listings Only option set to yes or no?

    Please advise.

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.