我有一个我正在循环的数组,每个循环我认为它会更新或添加到数据库,所以我可以在postmeta表中有多个产品ID,但它只添加最后一个并覆盖所有其他值。
有没有办法循环并添加每一个而不覆盖之前的循环?我已经尝试了update_和add_ post_meta两个具有相同的结果。
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>7.1.0</version>
</dependency>
答案 0 :(得分:0)
$number_products = get_price_cart_count();
$productIDsInCart = get_product_ids();
$throwback_ids = get_post_meta( '13376', 'product_ids', true );
$throwbackProducts = explode( ',', $throwback_ids );
$result = array_intersect($throwbackProducts, $productIDsInCart);
$data = implode( ',', $result);
update_post_meta( '683934', 'exclude_product_ids',$data);