function scrap_item($sku) { $sku = trim($sku); if (preg_match('%(AMZ|WM|OS|AL|HN|WF|B)(.*)%', $sku, $matches)) { switch ($matches[1]) { case 'B': $result = scrap_amazon('B' . $matches[2]); break; case 'WM': $result = scrap_walmart($matches[2]); break; case 'OS': $result = scrap_overstock($matches[2]); break; case 'AL': $result = scrap_aliexpress($matches[2]); break; case 'HN': $result = scrap_hayneedle($matches[2]); break; case 'WF': $result = scrap_wayfair($matches[2]); break; default: die("Unknown item '{$sku}'"); break; } } return $result; }
function delete_item_prime($itemid) { $result = array(); $active_user = 8; $sql = "SELECT * FROM user_products where UserID={$active_user} and ItemID={$itemid}"; $res = mysql_query($sql) or die('Something Wrong...!'); while ($row = mysql_fetch_array($res)) { $sku = trim($row['SKU']); $sku = str_replace(' ', '', $sku); $pattern = '/^AMZ/'; $posamaz = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); $pattern = '/^WM/'; $poswm = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); $pattern = '/^OS/'; $posos = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); $pattern = '/^AL/'; $posal = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); $pattern = '/^HN/'; $poshe = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); $pattern = '/^WF/'; $poswa = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE); if ($posamaz > 0) { $asin = str_replace('AMZ', '', $sku); $result = scrap_amazon($asin); } elseif ($poswm > 0) { $asin = str_replace('WM', '', $sku); //$tasin=explode('-',$asin); //$result=scrap_walmart($tasin[0]); } elseif ($posos > 0) { $asin = str_replace('OS', '', $sku); $result = scrap_overstock($asin); } elseif ($posal > 0) { $asin = str_replace('AL', '', $sku); $result = scrap_aliexpress($asin); } elseif ($poshe > 0) { $asin = str_replace('HN', '', $sku); $result = scrap_hayneedle($asin); } elseif ($poswa > 0) { $asin = str_replace('WF', '', $sku); $result = scrap_wayfair($asin); } else { $asin = $sku; $result = scrap_amazon($asin); } $item_id = $row['ItemID']; //echo $item_id;die; revise_ebay($result['offerprice'], $result['prime'], $result['quantity'], $result['scrapok'], $asin, $item_id); if ($result['prime'] == 'No') { $sql = "DELETE FROM ebay_asin where item_id=" . $item_id; $sql1 = "DELETE FROM user_products where ItemID=" . $item_id; mysql_query($sql); mysql_query($sql1); $date = date("d/m/Y h:i:s"); $message = "" . $date . " item for id=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a> is ended because <a '_blank' href=http://www.amazon.com/dp/" . $asin . ">" . $asin . "</a> doesnt have prime sellers <br>"; file_put_contents("log.php", $message, FILE_APPEND); $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail('*****@*****.**', 'Deleting Item', $message, $headers); //mail('*****@*****.**', 'Deleting Item', $message,$headers); mail('*****@*****.**', 'Deleting Item', $message, $headers); delete_item($item_id); } $check_request = getItem($item_id); $xml = simplexml_load_string($check_request); $status = $xml->Item->SellingStatus->ListingStatus; if (!empty($status) && $status != 'Active') { $sql = "DELETE FROM ebay_asin where item_id=" . $item_id; $sql1 = "DELETE FROM user_products where ItemID=" . $item_id; mysql_query($sql); mysql_query($sql1); } } }