Home>

I am creating a store on a CMS system. There is an API there. I have the following task: The client enters a number (product weight), then the price changes, depending on what the client wrote. The price should change not just visually, but go to the basket, check out and to the admin panel. There is

APISingleProductAddEdit:
type: object
properties:
sku:
type: string
example: "dkasj234"
description: The SKU od the product
model:
type: string
minimum:
type: integer
description: minimum items to add to cart
example: 10
upc:
type: string
description: UPC code for current product
weight:
type: integer
format: float
description: Numeric value of the weight of the product, if not passed it is zero
example: 40
weight_class_id:
type: integer
format: int32
description: The id of the weight class you are using for current product (There is separate API request that return all the weight classes, check "misc /dimension_lst")
example: 3
length:
type: integer
format: float
description: Numeric value of the length of the product, if not passed it is zero
example: 15
width:
type: integer
format: float
description: Numeric value of the width of the product, if not passed it is zero
example: 15
height:
type: integer
format: float
description: Numeric value of the height of the product, if not passed it is zero
example: 15
length_class_id:
type: integer
format: int32
description: The id of the length class you are using for current product (There is separate API request that return all the weight classes, check "misc /dimension_lst")
example: 3
stock_status:
type: integer
description: Valid stock status id (you can find them in separate API call the returns stock status ids)
example: 7
subtract:
type: integer
format: boolean
description: Pass '1' if you want to activate subtruct feature, if not pass '0'
sort_order:
type: integer
description: The order of the product related to another products
example: 9
status:
type: integer
format: boolean
description: If you want to disactivate the product pass '0' else pass '1'
keyword:
type: string
description: Keyword related to SEO
example: food
quantity:
type: integer
description: The quantity of your product
example: 10
hidden:
type: integer
format: boolean
example: 0
description: Hide your product from the customers by passing '1' else pass '0'
image:
type: string
description: Valid URL for valid image format (jpg, jpeg, png)
images:
type: array
items:
type: object
properties:
image:
type: string
description: Valid image url with valid image types same as the main image
sort_order:
type: integer
format: int64
description: The order of the curront image related to another images for this productprice: type: number
format: float
example: 56.76
product_related:
type: array
items:
type: integer
description: Each element in this array is product id that will be related to current product
example: [12,15,33]
product_category:
type: array
items:
type: integer
description: Each element in this array is category id that will be related to current product
example: [555,444,123]
product_description:
$ ref: '# /components /schemas /ProductLanguageObject''APISingleProductAddEdit:
type: object
properties:
sku:
type: string
example: "dkasj234"
description: The SKU od the product
model:
type: string
minimum:
type: integer
description: minimum items to add to cart
example: 10
upc:
type: string
description: UPC code for current product
weight:
type: integer
format: float
description: Numeric value of the weight of the product, if not passed it is zero
example: 40
weight_class_id:
type: integer
format: int32
description: The id of the weight class you are using for current product (There is separate API request that return all the weight classes, check "misc /dimension_lst")
example: 3
length:
type: integer
format: float
description: Numeric value of the length of the product, if not passed it is zero
example: 15
width:
type: integer
format: float
description: Numeric value of the width of the product, if not passed it is zero
example: 15
height:
type: integer
format: float
description: Numeric value of the height of the product, if not passed it is zero
example: 15
length_class_id:
type: integer
format: int32
description: The id of the length class you are using for current product (There is separate API request that return all the weight classes, check "misc /dimension_lst")
example: 3
stock_status:
type: integer
description: Valid stock status id (you can find them in separate API call the returns stock status ids)
example: 7
subtract:
type: integer
format: boolean
description: Pass '1' if you want to activate subtruct feature, if not pass '0'
sort_order:
type: integer
description: The order of the product related to another products
example: 9
status:
type: integer
format: boolean
description: If you want to disactivate the product pass '0' else pass '1'
keyword:
type: string
description: Keyword related to SEO
example: food
quantity:
type: integer
description: The quantity of your product
example: 10
hidden:
type: integer
format: boolean
example: 0
description: Hide your product from the customers by passing '1' else pass '0'
image:
type: string
description: Valid URL for valid image format (jpg, jpeg, png)
images:
type: array
items:
type: object
properties:
image:
type: string
description: Valid image url with valid image types same as the main imagesort_order: type: integer
format: int64
description: The order of the curront image related to another images for this product
price:
type: number
format: float
example: 56.76
product_related:
type: array
items:
type: integer
description: Each element in this array is product id that will be related to current product
example: [12,15,33]
product_category:
type: array
items:
type: integer
description: Each element in this array is category id that will be related to current product
example: [555,444,123]
product_description:
$ ref: '# /components /schemas /ProductLanguageObject'

I inserted the code from the API, as it seems to me, which is related to my task. How do I think to do it. I am creating a form where the client writes numbers, the function reads them and sends the value toprice: type: number format: float example: 56.76In general, the question is the following, how do you send data to the API at all? What should be done at least for this? Can I have an example?

Please clarify your specific problem or provide more detailed information on what exactly you need. As it stands, it is difficult to understand exactly what you are asking.

Дух сообщества2021-11-02 11:43:06

What is this CMS? If there is an API, maybe there is also documentation for it?

Simon2021-11-02 11:45:24

What you specified is the API, it describes how to access (GET, PUT, POST, DELETE) and what other requests do you need? And to the right, there are even examples in the form of json

Greg--2021-11-02 12:00:55

Send to https://ru.sellavi.com/gateway in your link above, so the request is written via ajax and process the result through js For example, enter in the browser (get a product with id 2) https://ru.sellavi.com/gateway/products /2 you will see an error because you need to generate a token, when you generate a token there will be a response in the form of json, but this is not the best example

Greg--2021-11-02 12:09:10

If you click in the right column Authorize and set any password, then when you click on try it out you will see the data in the format that your site will give you. As for me, the more correct method to make a request is js AJAX -a request in php and php already calls the CMS via API. But I'm a front-end developer, not a back-end developer, I could be wrong

Greg--2021-11-02 12:26:25