==================== AJAX PAGE ====================
| * Accessed via AJAX calls placed.
| * Either outputs as JSON or HTML formats.
|
| ----------- Table of Contents -----------
| START : Determine output content_type
| PREFIX : Print the prefix variable
| SUFFIX : Print the suffix variable
| END : Output the content_type header
| Features : JSON_Output certain features based off g.Action values
=START
=PREFIX
&mvte:output_prefix;
Process a comma separated list of Product IDs and return an array of "updates".
a) Inventory
b) Discount pricing
Verb: SS_Update_Product
Params:
❍ Product_IDS
validate data
validate id
Reset Foreach
"data": ,
"success": 1
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-003",
"message": "Error: Unable to ouput product list."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-002",
"message": "Error: Unable to create array from parameter `Product_IDS`."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-001",
"message": "Error: No product ids passed."
Get a specific product's attribute data (in JSON) via API
Verb: Get_Product_Attributes
Params:
❍ Product_ID
validate data
"data": ,
"success": 1
"data": [],
"success": 0,
"error_code": "AJAX-GPA-002",
"message": "Error: No attributes found."
"data": [],
"success": 0,
"error_code": "AJAX-GPA-001",
"message": "Error: No product id passed."
Get a specific content section's data via API
Verb: Get_ContentSection
Params:
❍ ContentSection_Code
Save a Kit state (JSON) into a file on the server for later recall
Verb: Set_Kit_Save
Params:
❍ Kit_UID
Request Body:
❍ JSON to be passed in body (refereneced by `s.content_data`)
Notes:
Saves the JSON to a file on the server.
"data": [],
"success": 0,
"error_code": "AJAX-SKS-001",
"message": "Error: No `Kit_UID` string passed."
=SUFFIX
&mvte:output_suffix;
Validate Kit_UID integrity
"data": [],
"success": 0,
"error_code": "AJAX-SKS-002",
"message": "Error: Passed `Kit_UID` is not valid."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-SKS-003",
"message": "Error: No data passed via request body."
=SUFFIX
&mvte:output_suffix;
attempt to decode json
"data": [],
"success": 0,
"error_code": "AJAX-SKS-004",
"message": "Error: Request body is not valid json."
=SUFFIX
&mvte:output_suffix;
define path
create/overwrite the file
"data": [],
"success": 1,
"message": "Success: Customization `&mvtj:global:Kit_UID;` was successfully edited!"
"data": [],
"success": 0,
"error_code": "AJAX-SKS-005",
"message": "Error: There was an error saving your customizations."
"data": [],
"success": 1,
"message": "Success: Created save for your customizations!"
"data": [],
"success": 0,
"error_code": "AJAX-SKS-006",
"message": "Error: There was an error saving your customizations."
Return a saved Kit state in JSON format, referenced by ID
Verb: Get_Saved_Kit
Params:
❍ Kit_UID
Notes:
Loads saved JSON file on the server
"data": [],
"success": 0,
"error_code": "AJAX-GSK-001",
"message": "Error: No `Kit_UID` string passed."
=SUFFIX
&mvte:output_suffix;
Validate Kit_UID integrity
"data": [],
"success": 0,
"error_code": "AJAX-SKS-007",
"message": "Error: Passed `Kit_UID` is not valid."
=SUFFIX
&mvte:output_suffix;
define path
"data": [],
"success": 0,
"error_code": "AJAX-GSK-002",
"message": "Error: No saved customization found with ID `&mvtj:global:Kit_UID;`."
=SUFFIX
&mvte:output_suffix;
"data": ,
"success": 1,
"error_code": "AJAX-GSK-003",
"message": "Success: Loaded saved customization."
"data": [],
"success": 0,
"error_code": "AJAX-GSK-004",
"message": "Error: There was an error loading the saved customization `&mvtj:global:Kit_UID;`."
Set the `kit_price` custom field via API call
Verb: Set_New_Kit_Price
Params:
❍ Product_ID
❍ New_Kit_Price
Notes:
Only works if the caller is logged into the customer login "kitprice".
validate data
"data": [],
"success": 0,
"error_code": "AJAX-SNKP-001",
"message": "Error: Product_ID was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-SNKP-002",
"message": "Error: New_Kit_Price was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-SNKP-003",
"message": "Error: View error in AJAX page template code."
=SUFFIX
&mvte:output_suffix;
Process Verb
"data": [],
"success": 1,
"message": "Success!"
Load a specific layout and product data into a "Kit" bundle to be used within the Pool Kit Builder app.
Verb: Get_Kit_Data
Params:
❍ Product_ID
Notes:
❍ CustomField_Codes — a comma separated list of custom field codes to load
❍ Relys on the `tgcomponent` item
❍ Relys on the `customfields` item
❍ Relys on the `product_attributes` item
❍ Requires `layout_code` customfield
validate data
"data": [],
"success": 0,
"error_code": "AJAX-GKD-001",
"message": "Error: Product_ID was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
sanitize/format data
================================================================================
Load Product Data
EXIT if failed to load product
"data": [],
"success": 0,
"error_code": "AJAX-GKD-002",
"message": "Error: Product_ID was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
Load Customfields
Load Attributes
Combine product and attribute data
Create `l.kit` structure
Output
"success": 1,
"data":
Load a variant and it's parts. Then load those part's "Kit Price"(kit_price) custom field value. Tally the "Sum of Parts" of the kit price.
Verb: Get_Variant_Kit_Price_SOP
Params:
❍ Product_ID -or- Product_Code
❍ Variant_ID
validate data
"data": [],
"success": 0,
"error_code": "AJAX-GVKPSOP-001",
"message": "Error: Product_ID or Product_Code was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-GVKPSOP-002",
"message": "Error: Variant_ID was not formatted correctly."
=SUFFIX
&mvte:output_suffix;
format data
"data": [],
"success": 0,
"error_code": "AJAX-GVKPSOP-004",
"message": "Error: No product found."
=SUFFIX
&mvte:output_suffix;
load data
"data": { "kitPrice": &mvtj:kit_price; },
"success": 1
=SUFFIX
&mvte:output_suffix;
"data": [],
"success": 0,
"error_code": "AJAX-GVKPSOP-003",
"message": "Error: No variant parts found."
=SUFFIX
&mvte:output_suffix;
=SUFFIX
&mvte:output_suffix;