Hi, great module. Since we have a lot of products to be imported, is it possible to automatically set quantity restrict whenever a product is created?

Since we are importing products programmatically, is there a way to set quantity restrict programmatically too?

Thanks very much.

Comments

victoria_b’s picture

Hi,

I have to agree - great module but automatically setting a default quantity whenever a product is created would be fantastic.

Thank you.

jamestombs’s picture

I have tried using hook_cart_item() which worked, but once you modify the products attributes you can't seem to remove it from the cart afterwards.

I have got it working using hook_add_to_cart_data($form_values), which does seem to work.

If you make sure your node object is passed in as a '#type' => 'value' then you can check for product type and return:

return array('restrict_qty' => 1); 

This is my full code:

function mymodule_add_to_cart_data($form_values) {
  if ($form_values['node']->type == 'mymoduleproduct') {
    return array('restrict_qty' => 1);
  }
}
asb’s picture

sub

raulmuroc’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Closed due to lack of activity.