How can I change the "Choose Option >>" button?

The product list grid view displays the "Choose Option >>" button under my products with variations. How can I change this to show a dropdown list of the variations and an "Add to Cart" button beneath it?

  • Charbean

    Hi Jack,

    Thanks for the reply.

    I was hoping the paid support we subscribed to here would include help on getting MarketPress to work for our site. We knew it wouldn't be exactly what we needed out of the box, but if we could get some direction we may be able to get things working the way we need. We're not afraid to dive into the code with some help.

    We were looking at marketpress-includes/template-functions.php

    Line 1794 looks to have the lines of code for the options button we want to change.

    if ($context == 'list') {
    	      if ($variation_select) {
            	$button .= '<a class="mp_link_buynow" href="' . get_permalink($post_id) . '">' . __('Choose Option &raquo;', '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 &raquo;', 'mp') . '" />';
    	      } else if ($mp->get_setting('list_button_type') == 'buynow') {
    	        $button .= '<input class="mp_button_buynow" type="submit" name="buynow" value="' . __('Buy Now &raquo;', 'mp') . '" />';
    	      }

    Line 1776 looks like the list we want?

    //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>&nbsp;\n";
    	 		} else {
    	      $button .= '<input type="hidden" name="variation" value="0" />';
    			}

    Maybe someone can offer a suggestion?

  • aristath

    Hello there @Charbean, I hope you're well today!
    You can follow one of these 2 options to make this work:

    1. Use WordPress translation (this plugin should do it: http://wordpress.org/extend/plugins/codestyling-localization/ ) to change the text there

    2. Change the "Choose Option" from this line:
    $button .= '<a class="mp_link_buynow" href="' . get_permalink($post_id) . '">' . __('Choose Option &raquo;', 'mp') . '</a>';

    I hope that helps!

    Cheers,
    Ari.

  • Charbean

    Hi aristath,

    Thank you for the reply. What we need though is to add the drop down list of variations beside or above an "Add to Cart" button for each product. So the function of the "Choose Options" button would need to change to an "Add to Cart" button, rather than just changing the label or text of the button.

    Right now if a customer wants to add a product to their cart, they have to click "Choose Options >>" and then be directed to the product page to select the variation and then add to their cart. We want our customers to be able to add items with variations to their cart right from the front page of the site.

    Thanks again!

  • aristath

    @Charbean ok, now I understand.
    What theme are you using?
    I'll try to recreate this on my installation and find a solution for you.
    Alternatively, you can send me your FTP credentials so that I may edit the template in your installation (that would save me the time of replicating your installation...)

    If you can do that simply send an email to aristath at incsub dot com
    - Include a link to this thread so that I may better track this issue.
    - Include your site's FTP credentials (user/pass)
    - Include a link to a page in your site where this should be applied.

    Cheers,
    Ari.

  • aristath

    This was easier than I expected... :slight_smile:
    On wp-content/plugins/marketpress/marketpress-includes/template-functions.php, line 1796 was like this:
    $button .= '<a class="mp_link_buynow" href="' . get_permalink($post_id) . '">' . __('Choose Option &raquo;', 'mp') . '</a>';
    I replaced it with this:

    $button .= $variation_select;
    $button .= '<input type="hidden" name="action" value="mp-update-cart" />';
    $button .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart &raquo;', 'mp') . '" />';

    and it now works the way you want it to. :slight_smile:
    Please note that you might want to remove the price displayed there since it's no longer necessary.
    You can do that either on that same file, or using css:
    span.mp_grid .mp_product_price{display: none;}

    I am now marking this issue as resolved.
    If however you need any further assistance don't hesitate to reopen this and post an update on your current status. :slight_smile:

    Cheers,
    Ari.

    Was that helpful?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.