Selective Money Order

Posts: 2
Joined: 05/07/2008

Hi Guys,
I am a newbie in Drupal. I have installed it just to run Ubercart, that seemed and is a great package.
i am running Ubercart for release 5. Please, don't tell me to update to release 6.

I am trying to configure my shop that will sell just downlodable goods.

So, a few issues raised. First, it is impossible to disable product weight.

Second, and this is my question, is that it is not possible to set up payments method to show or hide according to the user address. I ask this because I am trying to implement a method of payment by bank wire-transfer. To wire a money from a country to mine (Portugal) a customer has to follow 3 instructions, according to the country he/she lives:

1) if he is in Portugal
2) if he is in Euro zone
3) if he is in another place outside the euro zone and Portugal

But, I do not want to enable the wire transfer for customers outside the euro zone. So, at some point I need to test the custome's country to see if the method should be visible or not.

How can I do that. What code should I add? and where?

Thanks for any help.

regards

Posts: 3206
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

To answer the easy question first... you don't really need to disable the weight. Just set it to 0 and make sure the box is not checked that says "Product and its derivatives are shippable." If you do these, you won't see the shipping panes in checkout.

Regarding payment methods by country, this will be harder to achieve. As you've found out, there's no way to handle this in core. If you were to write a custom module to do it, you'd have two options:

  1. Make it like a regular payment method and just put in its description that it is only valid for people in the EU. Then you can use hook_form_alter() to run some code when the checkout review form is being loaded (see my free order contrib for an example). It's easy to check the country then, since you'll have an order object to work with. If they selected the payment method when they shouldn't have, give them an error message and send them back to the checkout form.
  2. Add some custom JS that hides the payment method option by default but adds an onchange function to the country select boxes. When someone chooses a country in the EU, use JS to show that selection. You'll still want to combine this with checking the country in PHP like I described above to make sure no one cheats. Eye-wink
Posts: 2
Joined: 05/07/2008

Hi Ryan,

It is sounding to me like you are talking martian... I will try to decypher what you said.

Can you tell me in which files 1 and 2 should be done?

regards

Posts: 3206
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hmm... guess I should've included the disclaimer... this requires custom Drupal module development. These things need to go in a separate module, but if you're not experienced in PHP or Drupal development, there's no way to make it happen.