Отправить значение из функции в api
Я создаю магазин на CMS системе. Там есть API. У меня стоит такая задача:Клиент вводит число (вес продукта), после меняется цена , в зависимости от того, что написал клиент. Цена должна меняться не просто визуально, а отправляться в корзину, чекаут и в админку. Есть
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 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 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'` 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 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 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'
Вставил тот код из API , как мне мне кажется, который относится к моей задаче. Как я думаю её выполнить. Я создаю форму, в которую клиент пишет цифры, функция их считывает и отправляет значение в
price: type: number format: float example: 56.76
В общем вопрос следующий, как вообще отправить данные в API ? Что хотя бы для этого нужно делать? Можно какой-то пример ?