11 replies [Last post]
Mariano's picture
Offline
Joined: 09/04/2007
Juice: 110
Was this information Helpful?

Hello everyone!

I just started using Übercart a couple of weeks ago. As for Drupal, already had been testing it for some months.
I am currently working on a website for an online drugstore. However, I haven't figured out how to restrict orders. FDA does not allow -for some medications- to buy more than one bottle or whatever. Say, you can't buy 3 bottles of Valium. So, I have to:

-> Restrict 'Quantity' for certain drugs

Moreover, FedEx is going to be the only shipping method (just for the USA). First I was told that $18 was the price for each order, regardless of the amount of pills ordered. But then, I was told that -e.g.- if you place together one order of Viagra (50 Tablets) and one order of Cialis (20 Tablets) then it would be $18 + $18 = $36 for the total shipping. So:

-> Charge $18 for each product ordered (within the same cart)

Please. Any ideas or suggestions would be very appreciated! =)

By the way, this is my first post here. I am learning on the way, but I want to learn a lot and be able to help the community, somehow.

M.

*So ein tolles System! Einfach geil ;)*

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Online Drugstore | Shipping Restrictions

I think you're the first person here who hasn't wanted the customer to buy as much as possible. This means that someone needs to write a custom module to get that to work. The inventory contribution is kind of similar, so it may be a good starting point.

The Flatrate module provides a shipping quote method that charges an amount per product in the cart. So if someone buys Viagra and Cialis, they will be charged $18 twice. Flatrate also charges for quantity, so buying two packages of Cialis would also be $36. If that's not what you want, you can easily modify Flatrate to do that. Just search for "qty".

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Online Drugstore | Shipping Restrictions

An idea for starting would be to use my product minimum contribution and change it a very little bit to work as a "product maximum" module. In other words, right now with that module you can specify a minimum number of a product that customers must order. You should be able to change just a little bit of text displayed to customers and one less than sign to a greater than sign and it'll work.

Mariano's picture
Offline
Joined: 09/04/2007
Juice: 110
Re: Re: Re: Online Drugstore | Shipping Restrictions

Hi, Ryan. I tried your 'product minimum' contribution and made the changes you suggested. It really worked! Smiling Thanks a lot for your help! I just modified the part of the minimum, and left the part about the 'sets of the minimum value' unchanged and unchecked.

Now I will try to figure out how to restrict users in certain states so that they can't buy prohibited medications. If anyone has got any idea ... please, I would like to know Sticking out tongue

Thanks again!

Mariano's picture
Offline
Joined: 09/04/2007
Juice: 110
Here I go again ... >_< I

Here I go again ... >_<

I thought that 'product maximum' was already set up, but I did some more tests and I got some errors. First, this line

'#default_value' => !empty($node->product_min) ? $node->product_min : 5,

defines the global maximum quantity for ordering medications as 5 , right? :s

For example, I defined a maximum quantity of 2 for Phentermine, and when I ordered 3, the error message displays correctly (and if I order exactly two or just one, then I get no error message at all, which is how it should be Smiling ). However, for Amoxicillin (which has no other maximum quantity defined -other than the global maximum quantity of 5-), at the checkout process I get the following error:

"You are not allowed to have more than orders of Amoxicillin 500 mg (30 Capsules) in your shopping cart."

Then, if I add another product (without maximum quantity defined) -e.g. Viagra-, then I get the same error:

"You are not allowed to have more than orders of Viagra 100 mg (10 Tablets) in your shopping cart."

So, it seems that unless the product has a specific maximum quantity defined, the shopping cart won't let the user buy it. I think it is not a big problem ... maybe I have to change something within the 'Callback Functions, Forms, and Tables' - I'm not quite sure, yet I don't know what or how.

Please, if someone could give me some advice on that ...
I think it would be useful if I include the uc_product_min.module file I edited.
A screenshot of the error as well.

Thanks in advance for any tips!

Mariano

AttachmentSize
message_error.jpg 29.48 KB
uc_product_min_module.zip 1.8 KB
Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Here I go again ... >_< I

Hey, almost there... that line you added won't actually set a global default, just the default for that field whenever the form is loaded. The module as is sort of works based on the global default of 1 (since we're talking about minimums, you'll have to have at least one in the cart).

If you want a global default for maximum, you need to check in uc_checkout_pane_product_min() to see if $min[$item->nid]['min'] is set first, and if not then set it to 5. Line 144 in the original file could be modified like so:

<?php
 
if ((isset($min[$item->nid]['min']) && $item->qty > $min[$item->nid]['min']) || $item->qty > 5)
?>

(Don't know if you're changing any variable names or not.)

Mariano's picture
Offline
Joined: 09/04/2007
Juice: 110
Wow, Ryan! You're amazing! I

Wow, Ryan! You're amazing!
I did exactly as you suggested ... and it works great!
Thanks a lot Eye-wink

I'll keep testing other modules. The contributions I've found are great. Incredible job, guys. Still, I wonder if it's possible to restrict users by aplying some rule when they buy medications in a state where that's not allowed. Have been looking for something, but I guess I'll just read on.

Thanks again Smiling

deciti's picture
Offline
Joined: 11/11/2007
Juice: 7
Re: Re: Here I go again ... >_< I

thanks ryan, this worked great for me as well. is there an easy way to have it change the quantity of the item to the maximum allowed?

so if they try to check out with five of an item but the max is three it automatically changes the quantity to three and then takes them to the checkout page.

Mariano's picture
Offline
Joined: 09/04/2007
Juice: 110
Hi again.

Hi again.

Well ... it is not that I really want customers to buy as few as possible. It's a matter of security, according to the FDA. I just can't go against their policies, or otherwise I could go to jail X______X

Anyway, I already configured the Flat Rate module, usind Flat Rate per product. However, under Shipping Quote Settings -> Quote Methods -> Flatrate, I tried setting up $18 for 'Default Product Shipping Rate', although it did not work. I mean, the shipping price at checkout was always $0. So, I just went product by product and entered $18 under 'Flat Shipping Rate'. It worked at last =)
Thanks for your help, Lyle!

As for the quantity maximum, I will try your 'product minimum' contribution, Ryan. Thanks for it. I'll let you know about it tomorrow.

I still have another question: Since it's not allowed to ship certain medications to some states in the USA, is it possible to create a rule (like the tax rule) in order to restrict users in restricted states from buying products which are not allowed by the FDA? In case they don't know or read the policies ...

Thanks again for your help!

Bis dann.

mandclu's picture
Offline
Bug Finder
Joined: 11/19/2007
Juice: 78
uc_product_max

I've updated the revised module to have its own name, so that theoretically someone can have a minimum on some products and/or a product maximum on other products. I also remove the references to multiples, as it didn't make sense to me in this context.

I did remove the default to a global, hard-coded maximum. I think my preference would be to have something you could set through Drupal, and leave it blank on an individual product to use the global maximum, or maybe even set zero to never use a maximum, regardless of what has been set globally.

I also added a few lines that will check on a product page if the current product has a product_max of one, and if so will ensure there is no quantity form element.

AttachmentSize
uc_product_max.zip 4.33 KB
Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: uc_product_max

Excellent! My recommendation would be to post it as a contribution so folks can find it easier. Thanks for taking the time to put it all together. Smiling

magnus's picture
Offline
Joined: 05/23/2008
Juice: 20
Added Views field

Hello,

I've added the product max field to use it in Views

It permits to add "Product: max per order" field a view.

function uc_product_max_views_tables(){
  $tables['uc_product_max'] = array(
    'name' => 'uc_product_max',
    'join' => array(
      'left' => array(
        'table' => 'node',
        'field' => 'nid',
        ),
      'right' => array(
        'field' => 'nid',
      ),
    ),
    'fields' => array(
        'product_max' => array(
        'name' => 'Product: Max per order',
        'help' => t(''),
        'field' => 'product_max',
      ),
    ),
  );
  return $tables;
}

This is simply added to the uc_product_max.module file.