Quantity Drop-down based on price break quantities

  • Posts: 43
  • Thank you received: 0
11 years 6 months ago #100418

Hi All,

I've seen the code to change the quantity field into a drop-down box, but I need to be able to set the drop-down values and display based on pricing information for a particular product. If "Product A" has pricing for quantities 1, 50, 150, and 500, I would like the dropdown to display those four values, with the price being the unit price for that price break times the quantity. The quantities and pricing will vary from one product to another. Having a quantity field in the cart is OK, as is the normal price break calculation.

It's in the "add to cart" display of the product that I need to perform this function.

I've taken the code suggested and have created the drop-down, but the quantities are hard coded. I've also used PHP print_r to see what, if any, values the $element, $obj, and $this vars might hold, but they seem to be empty. Are there any vars that would be available in the function defined in hikashop_button.php?

Thanks!

Sloan


Sloan Thrasher

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #100693

Hi,

No, you will have to load them yourself from the hikashop_price table with mysql query with a condition on the price_product_id using the cid value of $_REQUEST.

The following user(s) said Thank You: sloanthrasher

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 0
11 years 5 months ago #104273

Hi Nicolas,

I looked at that view, but it only seems to apply to displaying a single product. I want to display the quantity drop-down in a list of products. Is this the same view to edit, and if so, how do I know which product id applies each time it is called in the product list?

Thanks for your help!

Sloan


Sloan Thrasher

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #104275

Hi,

In that case, I recommend you to add a line of code like this in the listing_img_title view file (or the listing_table or another one based on the layout you're using) in order to set the current product id in the $_REQUEST like this:
<?php $_REQUEST = $this->row->product_id; ?>

Then, in your hikashop_button.php override, you will be able to load the data from the database based on $_REQUEST for listings.

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 0
11 years 5 months ago #104278

I'll check that out.

Is there any list of what view(s) apply where? I kind of see a naming pattern, but there are so many files, I haven't deciphered their meaning yet. There are several changes I need to make to the appearance of each product in the product listing, and how they behave.

I'm just starting some of this discovery, but I'll need to be able to make sure that when a user adds a product to the cart, it will be confirmed in a pop-up and they will stay on the current page. I'll also probably need to update a cart display module on the same page, but that hasn't been decided yet. IOW, the customer will see a list of products, with the current cart displayed in the left column, and as they add items, the cart would show the items that have been added. I haven't checked to see of the existing module will do this, but I suspect that it only updates when the page is displayed. At least that is what I would expect the module to do. I'll probably drop that feature if I can't figure out how to update the cart module using ajax or similar.

Sorry for the long reply.

I need to build a picture in my mind of what views are used where in the product list - how they relate, how they are nested, how they are called, that sort of thing.

BTW, the docs are pretty good, just a lot to take in all at once. I'm sure I've missed some critical bit in there that would give me the hint I need to understand the structure. I probably deserve a RTFM, but I am "reading the manual", it's just a bit slow going for me for now.

All that said, is there a place you can point me that might shed some light on there where's and how's?

Thanks!!


Sloan Thrasher

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #104359

There is no such list.
Look at the ctrl and task params of the URLs (with the SEF option of joomla turned off) and in general the ctrl value correspond to the view name and the task value correspond to the file name of the view file you're looking for.
Then, in a lot of view files and especially the big ones, we use the loadTemplate function to call sub view files (so that it is cleaner than having all the code in one file).

'm just starting some of this discovery, but I'll need to be able to make sure that when a user adds a product to the cart, it will be confirmed in a pop-up and they will stay on the current page. I'll also probably need to update a cart display module on the same page, but that hasn't been decided yet. IOW, the customer will see a list of products, with the current cart displayed in the left column, and as they add items, the cart would show the items that have been added. I haven't checked to see of the existing module will do this, but I suspect that it only updates when the page is displayed. At least that is what I would expect the module to do. I'll probably drop that feature if I can't figure out how to update the cart module using ajax or similar.

All that can already be done in HikaShop if configured properly without one line of code.
A good start will be to turn on the option "Use AJAX when possible for add to cart buttons" and change the option "After a product is added to the cart" to "stay and display a popup notice" in the configuration.

The following user(s) said Thank You: sloanthrasher

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 0
11 years 5 months ago #104389

Thanks Nicolas for all of you help!

I'll try and use the non-SEF trick to speed up my discovery process.


Sloan Thrasher

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum