Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

What's The Workflow To Display Quantity? Rate Topic   - - - - -

 
  • javier_p
  • Newbie
  • Trial users
  • Join Date: 30-Mar 19
  • 5 posts

Posted 30 March 2019 - 09:53 PM #1

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).

Thanks.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19060 posts

Posted 01 April 2019 - 02:09 PM #2

Do you want to make API call in template?


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • javier_p
  • Newbie
  • Trial users
  • Join Date: 30-Mar 19
  • 5 posts

Posted 01 April 2019 - 03:52 PM #3

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



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11249 posts

Posted 01 April 2019 - 08:33 PM #4

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • javier_p
  • Newbie
  • Trial users
  • Join Date: 30-Mar 19
  • 5 posts

Posted 01 April 2019 - 09:43 PM #5

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.

 



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11249 posts

Posted 02 April 2019 - 05:26 PM #6

"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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • javier_p
  • Newbie
  • Trial users
  • Join Date: 30-Mar 19
  • 5 posts

Posted 02 April 2019 - 06:17 PM #7

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.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19060 posts

Posted 03 April 2019 - 05:16 AM #8

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • javier_p
  • Newbie
  • Trial users
  • Join Date: 30-Mar 19
  • 5 posts

Posted 03 April 2019 - 07:21 PM #9

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



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11249 posts

Posted 03 April 2019 - 07:58 PM #10

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

check_add_to_cart_pre

check_add_to_cart_post

pre_add_to_cart

add_to_cart

post_add_to_cart


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19060 posts

Posted 04 April 2019 - 05:15 AM #11

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)


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.