4

I am using expresso store. I have 2 payment methods, offline payment and paypal. Currently it shows offline payment by default. How do I get paypal to be the default payment method?

<select id="payment_method" name="payment_method">
    {payment_method_options}
</select>
6

Elaborating on what was mentioned in the comments of your lincolnpixel's answer, and to provide an "official" response to why it works this way:

The correct way to specify a default is to hard code it in your template. There are a couple ways to do this. You can either specify it in your checkout tag:

{exp:store:checkout payment_method="paypal_express"}

Under the hood, this simply adds a hidden field to your template, so it's exactly the same as doing this:

<input type="hidden" name="payment_method" value="paypal_express" />

You can also template the input field however you like, such as a radio or select menu:

<select name="payment_method">
    <option value="paypal_express" selected>Paypal</option>
    <option value="manual">Manual</option>
</select>

The {payment_method_options} variable is really only a helper, and is by no means required.

The reason we implemented it this way is simple: when we designed Store, we took a step back and thought about how ecommerce should work in an ExpressionEngine context. Most ecommerce systems let you set up things like default payment methods (and drag and drop reordering of payment methods) because you are using off-the-shelf templates, which cater to users who don't like to get their hands dirty with HTML.

However, since with EE you are already coding the HTML from scratch, it seemed like a waste of time having to tell yourself what the default payment method is in the back end, then provide a bunch of template tags which let you display the default payment method you just configured. To ExpressionEngine developers it feels much more natural just to specify how things should work in the template (just as you do with a contact form, where you specify the destination email address in the template, and most other plugins have examples like this too).

Most sites only have a single payment method, so hard coding it in the template (alongside the fields required for that payment method, when you take credit cards directly on your site) makes the most sense for that scenario. When multiple payment methods are available, it's often nice to use radio buttons and display a logo next to each one, which would require extra template code anyway, so {payment_method_options} isn't very useful there.

TL;DR: In most cases you will should hard code your payment_method select/radio/hidden field directly in your template. The {payment_method_options} variable is only a helper, and is certainly not intended to be the only way to display payment methods to your customers.

1

You can manually code it since the payment methods are limited to 2

<select name="payment_method">
<option value="paypal_express">Paypal</option>
<option value="manual">Manual</option>
</select>

You can do that by simply making sure that in Store - Payment Methods settings, Paypal is the first in order.

  • That doesn't really answer my original question which 'how do you set a payment method to be selected by default?'. It's more of a workaround, which is great and works in my case, doesn't really answer the question though which is why I haven't checked it as an accepted answer. I thought the developers of store my be able to shed some light on this. – Steve Jan 17 '13 at 12:34
  • The documentation states that, 'Payment Methods allows you to configure the payment options which will be available to customers during checkout. You can then display these options to your customers as a select menu, or hard-code the selected payment method in to your templates.' So it seems as if that is the intended behavior, that you select the default on the template, not in the control panel. See: exp-resso.com/docs/store/settings_payment_methods.html – nonprofit_tech Jan 17 '13 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.