I am trying to make my quotes deduct from my stock numbers automatically. I have been advised to use a Before_Save Logic Hook to make this work. However i am new to logic hooks and am unsure how to write this.
Here is what i am trying to do.
In Products i have created 3 new fields.
-*Stock_Allocated_C
-*Stock_Available_C
-*Stock_C
Each of these fields is a text field and has a number in them.
When a Quote gets the status of “Confirmed” i want it to then look for the fields under “Line Items” section on the Edit View on quotes.
There are 2 Fields
-Part_Number
-Product_QTY
The Part_Number field already links to Products and identifies its corresponding product by default.
The Product_QTY Field does not link to any of the products fields. I am trying to make this so when we confirm a quote it will then ‘-’ the number from Stock available and add it to stock allocated.
Is this possible? if so has anybody done this before?
I am struggling to get any information on how to write this code i want.
I want the logic hook to do the following.
From Quotes > Line Items i want it to use the “Part_Number” and search products for the “Part_Number” They are 2 different fields in 2 Different Modules.
Once it finds the match i want it to then.
Use Quantity (From Quotes>Line Items) and update my 2 custom fields in Products which are “Stock_Allocated_C” (It will add the amount from quantity) and “stock_available_c” (It will take the number away from this amount.)
Can anyone possibly help with this please?
I have tried to follow the guides but they dont come close to what i am trying to accomplish
I have customized line items and products to meet my requirements. My current issue is this:
Using a logic hook in AOS_Quotes to “move” stock into “allocated” once a quote becomes approved isn’t easy due to the fact that you are technically dealing with two different modules. AOS_Products_Quotes and AOS_Products.
Line Items seems to be loaded into AOS_Quotes. I am unsure how to read Line Items within Quotes. Quotes is where the logic hook would be located.
Line items are records saved in AOS_Products_Quotes. To define the relationship with either Quotes, Invoices or Contracts, line items uses field ‘parent_name’ and ‘parent_id’ to define that.
So if you want to know what products were allocated to a specific Quote, you need to load the beans or query the AOS_Products_Quotes records where the ‘parent_name’ = AOS_Quotes and the ‘parent_id’ = the current quote id.