Issue With Plugin with WP Lister
-
Hi All,
There is an issue with compatibility with 3rd party plugin such as WPLister (eBay/Amazon), where as orders placed via these do not link directly to a product, so the following code crashes when completing an order
foreach ($items as $row) { $productmeta = wc_get_product($row['product_id']); $sku = get_option('product_identifier') == 'id' ? $row['product_id'] : $productmeta->get_sku(); if ($productmeta->get_type() == 'variable' && get_option('use_parent_product') != 1) { $available_variations = $productmeta->get_available_variations(); foreach ($available_variations as $variation) { if ($variation['variation_id'] == $row['variation_id']) { $sku = get_option('product_identifier') == 'id' ? $variation['variation_id'] : $variation['sku']; } } }
Basically you would need to add some error checking into $productmeta to make sure that a product is found before proceeding – i.e.
foreach ($items as $row) { $productmeta = wc_get_product($row['product_id']); if(isset($productmeta)){ $sku = get_option('product_identifier') == 'id' ? $row['product_id'] : $productmeta->get_sku(); if ($productmeta->get_type() == 'variable' && get_option('use_parent_product') != 1) { $available_variations = $productmeta->get_available_variations(); foreach ($available_variations as $variation) { if ($variation['variation_id'] == $row['variation_id']) { $sku = get_option('product_identifier') == 'id' ? $variation['variation_id'] : $variation['sku']; } } } $url = get_permalink($row['product_id']); $attachment_url = wp_get_attachment_url(get_post_thumbnail_id($row['product_id'])); if (!(get_option('disable_reviews_per_product') == '1' && $productmeta->post->comment_status == 'closed')) { $p[] = array( 'sku' => $sku, 'name' => $row['name'], 'image' => $attachment_url, 'pageUrl' => $url, ); } } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Issue With Plugin with WP Lister’ is closed to new replies.