clawrock/m2-product-shipping

模块负责在产品查看页面上显示运输方式。

1.0.0 2018-03-15 11:40 UTC

This package is auto-updated.

Last update: 2024-08-29 04:49:44 UTC


README

模块负责使用预定义的国家显示产品查看页面上可用的运输方式。

要求

  1. Magento 2.1+

安装(使用composer)

  1. composer require clawrock/m2-product-shipping
  2. php bin/magento setup:upgrade

安装(手动)

  1. 将仓库克隆到 app/code/ClawRock/ProductShipping
  2. php bin/magento setup:upgrade

配置

  1. 转到 Stores -> Configuration -> ClawRock -> Product Shipping
  2. 选择用于计算可用运输方式的国家,否则将不会返回运输方式
  3. 您还可以编辑当API返回空数组(找不到运输方式)时显示的消息

API

您可以使用API请求获取产品的运输方式。

Endpoint: rest/V1/product-shipping-methods
Method: POST

简单产品

主体

options: {
  "qty": 1,
  "sku": "S03"
}

可配置产品

主体

options: {
  "super_attribute": {
    "142":"167",
    "93":"58"
  },
  "qty": 1,
  "sku": "WS03"
}

super_attribute 数组中的键是超级属性ID,值是选项ID,例如 142color 属性,167red 选项。

捆绑产品

主体

options: {
  "bundle_option": {
    "1" : [3]
  },
  "bundle_option_qty": {
    "1": 5
  },
  "qty": 1,
  "sku": "24-WG080-1"
}

bundle_option 数组中的键是选项ID,值是选择ID。一个选项中可能有多个选择,即多选或复选框。在 bundle_option_qty 数组中的键是选项ID,值是选项的数量。

测试

要在控制台中运行测试,请执行:vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist