pgtg
Forum Replies Created
-
Hi kowjirow,
your problem is completely different, your JS scripts crashed and it most likely has nothing to do with this plugin. Disable autoptimize first to find out which scripts are causing the problem. I think it’s not the fault of this plugin, it doesn’t have too many JS scripts added to “Add to cart form”. When you turn off the cache/autoptimize, you will see what is throwing errors except Facebook on your website.
If you don’t have basic programming skills, I’m afraid you’ll have to use someone who does.
Have a nice day,
Pawe?Hi kowjirow,
simple script getting all products, next checking if they have woosb_ids meta, next if needed recreate meta to new version with required fields only and saving it to database. To use it save it in php file in the same catalog where you have wp-config and run it.
<?php require_once(__DIR__ . '/wp-load.php'); $products = wc_get_products(['limit' => -1, 'return' => 'ids']); foreach ($products as $product_id) { $meta = get_post_meta($product_id, 'woosb_ids'); if ($meta && count($meta) && !is_array($meta['0'])) { $meta = getProductsFromMeta($meta['0']); if($meta) update_post_meta($product_id, 'woosb_ids', $meta); } } function getProductsFromMeta($meta) { $output = []; $produkty = explode(",", $meta); foreach ($produkty as $singleProduct) { $productData = explode("/", $singleProduct); $product = wc_get_product($productData['0']); if(!$product) return false; $output[generateKey()] = ['id' => $productData['0'], 'sku' => $product->get_sku(), 'qty' => $productData['1']]; } return $output; } function generateKey() { $key = ''; $key_str = 'abcdefghijklmnopqrstuvwxyz0123456789'; $key_str_len = strlen($key_str); for ($i = 0; $i < 4; $i++) { $key .= $key_str[random_int(0, $key_str_len - 1)]; } if (is_numeric($key)) { $key = generateKey(); } return $key; }
The script is simple, I didn’t want to write checking the product type at the beginning or adding additional, unnecessary fields to output, I only did it to make the bundles available for purchase again.
Hope that it will help you,
Have a nice day,
Pawe?Hi All,
problem is a little bit different, there is 2 types of products, products added (and not edited) before plugin version 7 and newer, added or edited after version 7. This version complicity changed way how products data is stored in database – woosb_ids in wp_postmeta.
Before was:
151/1,1276/1
After editing / saving again in database is:
a:2:{s:4:"u3g2";a:5:{s:2:"id";s:3:"151";s:3:"sku";s:13:"28-BU068-1000";s:3:"qty";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}s:4:"94yl";a:5:{s:2:"id";s:4:"1276";s:3:"sku";s:4:"TS06";s:3:"qty";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}}
I wrote for myself a simple script which is changing the way how bundles are stored in database and my problem did not occur again.
Hope that this will help someone in future.
Have a nice day and thank you for creating that brilliant plugin!