Php WP All导入添加带有原始数据的post钩子
我使用WP All Import和WooCommerce附加组件在WooCommerce中导入产品。在原始xml中,我为不同的用户角色提供了3个折扣类别。通过WooCommerce()的客户特定定价插件,我可以为这些角色显示不同的价格 此插件将其数据保存到单独的表中(Php WP All导入添加带有原始数据的post钩子,php,wordpress,wpallimport,Php,Wordpress,Wpallimport,我使用WP All Import和WooCommerce附加组件在WooCommerce中导入产品。在原始xml中,我为不同的用户角色提供了3个折扣类别。通过WooCommerce()的客户特定定价插件,我可以为这些角色显示不同的价格 此插件将其数据保存到单独的表中(wp\u wusp\u role\u pricing\u mapping),这意味着wp All Import无法直接插入数据 但是,WP All Import有一个hookpmxi\u saved\u post,每次保存或更新po
wp\u wusp\u role\u pricing\u mapping
),这意味着wp All Import无法直接插入数据
但是,WP All Import有一个hookpmxi\u saved\u post
,每次保存或更新post时都会调用它。()
在该函数中,我必须能够将记录插入wusp_role_price_映射表,因为我需要post_id,但这就是我的问题:我还需要来自XML的原始数据,其中有单独的折扣规则。我可以在钩子操作中访问该数据吗
请注意,这是数据在xml中的外观,以及它必须如何保存在数据库中
<Korting>
<KortingCategorie>EH Markt 71 %</KortingCategorie>
<Percentage>40</Percentage>
<Prijs>0,0000</Prijs>
<KortingCategorie>EH winkel 35%</KortingCategorie>
<Percentage>40</Percentage>
<Prijs>0,0000</Prijs>
<KortingCategorie>EH Winkel 45%</KortingCategorie>
<Percentage>40</Percentage>
<Prijs>0,0000</Prijs>
<KortingCategorie>EH Winkel 50%</KortingCategorie>
<Percentage>40</Percentage>
<Prijs>0,0000</Prijs>
</Korting>
刚刚找到另一个解决方案: 通过导入,我将折扣组添加到自定义字段,通过钩子和
get\u post\u meta
和wpdb->insert()
函数,我在正确的位置添加正确的值
+----+--------------+---------+---------+------------------------+------------+
| id | role | price | min_qty | flat_or_discount_price | product_id |
+----+--------------+---------+---------+------------------------+------------+
| 1 | eh_winkel_50 | 40.0000 | 1 | 2 | 5445 |
| 2 | eh_winkel_45 | 40.0000 | 1 | 2 | 5445 |
| 3 | eh_markt | 40.0000 | 1 | 2 | 5445 |
+----+--------------+---------+---------+------------------------+------------+