X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Allow customers to order a product in specific quantities only (https://forum.x-cart.com/showthread.php?t=77199)

welly 09-23-2019 03:02 AM

Allow customers to order a product in specific quantities only
 
Hi there

Is it possible to force customers to order specific quantities of a product? I'm sure this could be done in 4.x although I never tried it myself, but I can't find any way to do it in 5.x.

For example, I want to offer one of my products in quantities of 32, 64, 96, 128, and 250. I would prefer not to make the quantity an option/variant (eg, 'pack size'), as I think there will be far too many variants this way.

The product in question has 6 base styles and two print options. Each style is priced individually, and there is a per-unit price uplift on one of the print options (the price uplift is the same regardless of the base style).

I admit that my products are usually configured in a very basic way and I try to have only few variants. There are probably some simple ways to achieve what I want. I just don't know what they are!

Many thanks

Welly

cflsystems 09-23-2019 05:29 AM

Re: Allow customers to order a product in specific quantities only
 
Not without custom coding it. I did a similar one for a client not long ago.

welly 09-23-2019 05:42 AM

Re: Allow customers to order a product in specific quantities only
 
Thanks, Steve. I thought that might be the answer.

As it is only for one product, I'll see if I can achieve what I want a different way.

Cheers

Welly

Ed B. 09-29-2019 08:35 AM

Re: Allow customers to order a product in specific quantities only
 
If I am not mistaken, the subject is treated on the page https://devs.x-cart.com/changing_store_logic/forcing_product_quantity_while_adding_to_cart.html

welly 09-30-2019 07:26 AM

Re: Allow customers to order a product in specific quantities only
 
That is a good spot, Ed, many thanks, and a solution might well be derived from that, but I assume it would globally affect all products, and would require some customisation to restrict it to a single one.

I'm not sure I have the skills or inclination for that, but I really appreciate the pointer.

Many thanks

Welly

Ed B. 09-30-2019 09:23 PM

Re: Allow customers to order a product in specific quantities only
 
If there is just one product, and if its product id doesn't change (it won't unless you remove from and add again to the catalog), probably all you need is to add an if clause like
Code:

if ($item->getProductId()=x){
}

(here x is the product id of your product) in an appropriate place in the code.


All times are GMT -8. The time now is 03:31 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.