Can I turn off product listings in Market Press Pro for specific product pages?

Certain products on the site require filling out a form, others do not. I am using a Formidable Forms plugin to create the forms, which submit via email. I'd like to remove the "Add To Cart" button below the form so users only have one option: Submit Form. Upon submittal, they will be redirected to an "Add To Cart" page.

  • Vaughan

    Hi shannon,

    Hope you're well?

    How does your add-to-cart page work?

    I might know of a possible solution for this using some custom code & making use of a specific category.

    First create a category in marketpress in the example i'll call it 'specialist'

    Now add each of the products you want to use the form with to the specialist category.

    Now add the following code to your theme functions.php

    /*
     * Displays the buy or add to cart button
     *
     * @param bool $echo Optional, whether to echo
     * @param string $context Options are list or single
     * @param int $post_id The post_id for the product. Optional if in the loop
     */
    
    function mp_buy_button($echo = true, $context = 'list', $post_id = NULL) {
    		global $id, $mp;
    		$post_id = ( NULL === $post_id ) ? $id : $post_id;
    
                    $special_category = 'specialist';
    
    		$meta = (array) get_post_custom($post_id);
    		//unserialize
    		foreach ($meta as $key => $val) {
    				$meta[$key] = maybe_unserialize($val[0]);
    				if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file")
    						$meta[$key] = array($meta[$key]);
    		}
    
    		//check stock
    		$no_inventory = array();
    		$all_out = false;
    		if ($meta['mp_track_inventory']) {
    				$cart = $mp->get_cart_contents();
    				if (isset($cart[$post_id]) && is_array($cart[$post_id])) {
    						foreach ($cart[$post_id] as $variation => $data) {
    								if ($meta['mp_inventory'][$variation] <= $data['quantity'])
    										$no_inventory[] = $variation;
    						}
    						foreach ($meta['mp_inventory'] as $key => $stock) {
    								if (!in_array($key, $no_inventory) && $stock <= 0)
    										$no_inventory[] = $key;
    						}
    				}
    
    				//find out of stock items that aren't in the cart
    				foreach ($meta['mp_inventory'] as $key => $stock) {
    						if (!in_array($key, $no_inventory) && $stock <= 0)
    								$no_inventory[] = $key;
    				}
    
    				if (count($no_inventory) >= count($meta["mp_price"]))
    						$all_out = true;
    		}
    
           $terms = get_the_term_list($post_id, 'product_category', '', ',', '');
    
    		//display an external link or form button
            if(strpos($terms,$special_category)) {
                $button = '';
            } else if (isset($meta['mp_product_link']) && $product_link = $meta['mp_product_link']) {
    
    				$button = '<a class="mp_link_buynow" href="' . esc_url($product_link) . '">' . __('Buy Now »', 'mp') . '</a>';
    		} else if ($mp->get_setting('disable_cart')) {
    
    				$button = '';
    		} else {
    				$variation_select = '';
    				$button = '<form class="mp_buy_form" method="post" action="' . mp_cart_link(false, true) . '">';
    
    				if ($all_out) {
    						$button .= '<span class="mp_no_stock">' . __('Out of Stock', 'mp') . '</span>';
    				} else {
    
    						$button .= '<input type="hidden" name="product_id" value="' . $post_id . '" />';
    
    						//create select list if more than one variation
    						if (is_array($meta["mp_price"]) && count($meta["mp_price"]) > 1 && empty($meta["mp_file"])) {
    								$variation_select = '<select class="mp_product_variations" name="variation">';
    								foreach ($meta["mp_price"] as $key => $value) {
    										$disabled = (in_array($key, $no_inventory)) ? ' disabled="disabled"' : '';
    										$variation_select .= '<option value="' . $key . '"' . $disabled . '>' . esc_html($meta["mp_var_name"][$key]) . ' - ';
    										if ($meta["mp_is_sale"] && $meta["mp_sale_price"][$key]) {
    												$variation_select .= $mp->format_currency('', $meta["mp_sale_price"][$key]);
    										} else {
    												$variation_select .= $mp->format_currency('', $value);
    										}
    										$variation_select .= "</option>\n";
    								}
    								$variation_select .= "</select> \n";
    						} else {
    								$button .= '<input type="hidden" name="variation" value="0" />';
    						}
    
    						if ($context == 'list') {
    								if ($variation_select) {
    										$button .= '<a class="mp_link_buynow" href="' . get_permalink($post_id) . '">' . __('Choose Option »', 'mp') . '</a>';
    								} else if ($mp->get_setting('list_button_type') == 'addcart') {
    										$button .= '<input type="hidden" name="action" value="mp-update-cart" />';
    										$button .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart »', 'mp') . '" />';
    								} else if ($mp->get_setting('list_button_type') == 'buynow') {
    										$button .= '<input class="mp_button_buynow" type="submit" name="buynow" value="' . __('Buy Now »', 'mp') . '" />';
    								}
    						} else {
    
    								$button .= $variation_select;
    
    								//add quantity field if not downloadable
    								if ($mp->get_setting('show_quantity') && empty($meta["mp_file"])) {
    										$button .= '<span class="mp_quantity"><label>' . __('Quantity:', 'mp') . ' <input class="mp_quantity_field" type="text" size="1" name="quantity" value="1" /></label></span> ';
    								}
    
    								if ($mp->get_setting('product_button_type') == 'addcart') {
    										$button .= '<input type="hidden" name="action" value="mp-update-cart" />';
    										$button .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart »', 'mp') . '" />';
    								} else if ($mp->get_setting('product_button_type') == 'buynow') {
    										$button .= '<input class="mp_button_buynow" type="submit" name="buynow" value="' . __('Buy Now »', 'mp') . '" />';
    								}
    						}
    				}
    
    				$button .= '</form>';
    		}
    
    		$button = apply_filters('mp_buy_button_tag', $button, $post_id, $context);
    
    		if ($echo)
    				echo $button;
    		else
    				return $button;
    }

    You can create any category you like, but you must make sure you change the following line in the code above to the same category name.

    $special_category = 'specialist';

    Now, for any products in the specialist category, you will not see an add to cart button or buy now button.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.