What's The Workflow To Display Quantity?

Hi, I need to modify the amount of items based on an Api. I think of checking it twice, first on product display and then on chekout.

Found this one on default.template.tpl :

{assign var="product_amount" value="product_amount_`$obj_id`"}

But would like to know if a hook is enough (idea being use hook to query on Api and then assign value).


Do you want to make API call in template?

Hi eComLabs. Not necessarily in template, but was wondering where does the database gets the query from, part I found was product_amount.

Amount (product quantity) can be adjusted via api as

{amount: [quantity_on_hand]}

where '[quantity_on_hand]' is an integer value

I WOULD NOT recommend using a template hook to modify the quantity.

Please explain in more detail what you are trying to do and why.

Thanks tbirnseth, I'm in need to update based on an API from an in-store system, so it's not feasible to rely on cron updates. What file(s) actually query the database, or the flow. Idea now is:

Query product -> consult stock (based on in-store API) -> update amount in stock (APi maybe, or direct sql) -> display product with updated stock.

"Pulling" information from your in-store API or "pushing" is perfectly suited to a cron job. So not quite sure where you're coming from

If you can provide definition of your API, we can certainly build you an addon that will periodically update price or any other product field based on your needs.

Unfortunately a cron job is not viable as product might have been sold in store just a few seconds before the client tries to purchase, we need realtime communication. Thanks anyway.

I suggest you to get available qty:

- daily by cron

- at the moment when product is added to cart

- at the moment when the order is placed

CS-Cart has hooks for these actions

Hi eComLabs, would you mind sharing which hook is called when a product is added to cart?

There are several at various stages of the 'add' process.






Hi eComLabs, would you mind sharing which hook is called when a product is added to cart?

You can find necessary hooks in the fn_add_product_to_cart function (app/functions/fn.cart.php)