function wpla_product_admin_notices() { global $post, $post_ID; if (!$post) { return; } if (!$post_ID) { return; } if (!$post->post_type == 'product') { return; } $errors_msg = ''; // warn about missing details $this->checkForMissingData($post); $this->checkForInvalidData($post); // get listing item $lm = new WPLA_ListingsModel(); $listing = $lm->getItemByPostID($post_ID); if (!$listing) { return; } // parse history $history = maybe_unserialize($listing->history); if (empty($history) && $listing->product_type != 'variable') { return; } // echo "<pre>";print_r($history);echo"</pre>";#die(); // show errors and warning on online and failed items only if (!in_array($listing->status, array('online', 'failed'))) { return; } // process errors and warnings $tips_errors = array(); $tips_warnings = array(); if (is_array($history)) { foreach ($history['errors'] as $feed_error) { $tips_errors[] = WPLA_FeedValidator::formatAmazonFeedError($feed_error); } foreach ($history['warnings'] as $feed_error) { $tips_warnings[] = WPLA_FeedValidator::formatAmazonFeedError($feed_error); } } if (!empty($tips_errors)) { $errors_msg .= 'Amazon returned the following error(s) when this product was submitted.' . ' '; $errors_msg .= '(Status: ' . $listing->status . ')<br>'; $errors_msg .= '<small style="color:darkred">' . join('<br>', $tips_errors) . '</small>'; } // check variations for errors if ($listing->product_type == 'variable') { $variations_msg = $errors_msg ? '<br><br>' : ''; $variations_msg .= '<small><a href="#" onclick="jQuery(\'#variation_error_container\').slideToggle();return false;" class="button button-small">' . 'Show errors for all variations' . '</a></small>'; $variations_msg .= '<div id="variation_error_container" style="display:none">'; $variations_have_errors = false; $child_items = $lm->getAllItemsByParentID($post_ID); foreach ($child_items as $child) { $history = maybe_unserialize($child->history); $tips_errors = array(); if (is_array($history)) { foreach ($history['errors'] as $feed_error) { $tips_errors[] = WPLA_FeedValidator::formatAmazonFeedError($feed_error); } // foreach ( $history['warnings'] as $feed_error ) { // $tips_warnings[] = WPLA_FeedValidator::formatAmazonFeedError( $feed_error ); // } } if (!empty($tips_errors)) { $variations_msg .= 'Errors for variation ' . $child->sku . ':' . '<br>'; $variations_msg .= '<small style="color:darkred">' . join('<br>', $tips_errors) . '</small><br><br>'; $variations_have_errors = true; } } $variations_msg .= '</div>'; if ($variations_have_errors) { $errors_msg .= $variations_msg; } } if ($errors_msg) { self::showMessage($errors_msg, 1, 1); } }