简体   繁体   English

Woocommerce中某些产品的批量更新成本

[英]Bulk update cost on certain products in Woocommerce

I'm trying to bulk update the cost of certain items on my store. 我正在尝试批量更新商店中某些商品的费用。 I found this thread where a user says the following code can bulk update price: 我在用户说以下代码可以批量更新价格的地方找到了该线程

UPDATE wp_postmeta m 
    JOIN wp_posts p ON m.post_id=p.id 
    AND m.meta_key = '_price' 
    AND p.post_type = 'product'
SET m.meta_value = <price>

I'm gonna assume if I change _price to _cost it will work. 我假设如果我将_price更改为_cost ,它将起作用。 Is that the correct term, or does anyone know how I can find it? 那是正确的术语,还是有人知道我可以找到它吗?

More importantly, am I able to target certain products by their categories or tags? 更重要的是,我可以按类别或标签定位某些产品吗? If so, how? 如果是这样,怎么办?

There is no term like _cost in woocommerce. _cost没有_cost的术语。

There are 3 terms that WooCommerce use to store data in database: WooCommerce使用3个术语在数据库中存储数据:

1) _regular_price : As the name suggests, It is for the regular price of the product. 1) _regular_price :顾名思义,它是产品的正常价格。

2) _sale_price : As the name suggests, It is for the sale price if the product is on sale and if product is not on sale then it will use _regular_price . 2) _sale_price :顾名思义,如果产品正在销售,则用于销售价格 ;如果产品不销售,则将使用_regular_price

3) _price : Product is going to be sell based on _price . 3) _price :将根据_price出售产品。 So suppose you have on product which is having _regular_price 22 $ and _sale_price 18 $ then product is going to sell at 18 $ . 因此,假设你有在其上有产品_regular_price $ 22_sale_price $ 18则产品将在18 $卖。 So basically you can say _price is decide by the regular_price and _sale_price both. 因此,基本上可以说_price是由决定regular_price_sale_price两者。

So there is not _cost term as per my knowledge and experience. 因此,根据我的知识和经验,没有_cost术语。


Yes you can target particular category but you need to dig in to database. 是的,您可以定位特定类别,但需要深入数据库。

First step : Go to your database and find wp_terms table( wp is prefix and it might be different in your case). 第一步 :转到数据库,找到wp_terms表( wp是前缀,在您的情况下可能有所不同)。

Step 2 : Find term_id of your category. 步骤2 :找到您类别的term_id

All the category assigned to the product in wp_term_relationships . wp_term_relationships中分配给产品的所有类别。

So you can write your query and put condition like id(wp_post table) = object_id(wp_term_relationships table) . 因此,您可以编写查询并放入条件,例如id(wp_post table) = object_id(wp_term_relationships table)

NOTE: Object ID and Post ID both are same in your database. 注意:对象ID和发布ID在数据库中都相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM