dongshai2022 2019-04-12 10:30 采纳率: 100%
浏览 82

REST API插入的WooCommerce产品WPML翻译不包括原始产品的变体

Unfortunately I'm working with wordpress and woocommerce, what I'm trying to accomplish is to insert products and relative translations using the woocommerce REST API, here's the scenario:

  • First, i create a simple product
{
 "name": "Dummy",
 "type": "variable",
 "attributes": [
     {
         "id": 2,
         "name": "Color",
         "position": 1,
         "variation": "true",
         "options": [
             "Bianco",
             "Nero"
         ]
     },
     {
         "id": 3,
         "name": "Size",
         "position": 2,
         "variation": "true",
         "options": [
             "A",
             "B",
             "C"
         ]
     }
 ]
}

This is a variable product, so I need to create its variations as well The product created return its id, let's say 10

{
    "regular_price": "10.10",
    "stock_quantity": 10,
    "attributes": [
        {
            "id": 2,
            "name": "Color",
            "option": "Bianco"
        },
        {
            "id": 3,
            "name": "Size",
            "option": "A"
        }
    ]
}
  • So I have a product with variations, now i want to create a translation of the product with wpml, according to wmpl rest api specifications, I create a product translation like this:
{
    "name": "Dummy en",
    "type": "variable",
    "lang": "en",
    "translation_of": 10
}
  • I specified the language en, the main language is it
  • I included translation_of with the id of the original product

What happens is that the english product is created, but without variations

What I have tried:

  • Several issues similar to this are solved by the troubleshooting page of wpml, where I can generate missing variations but I need this to be done automatically, products are created automatically, so relative translations too must be
  • If I enter product page from wordpress back end and I press the update button, variations are created and adjusted, this word for the original product and the variation, but again, I need this to be done automatically
  • I tried to modify and insert the translation in almost all ways, adding/removing sku, id, attributes, categories ecc.

Any hints? Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体