/** * delete a number of product * * @return array status */ function Products_adminProductsDelete() { $ids_to_check = $_REQUEST['ids']; if (!count($ids_to_check)) { return array('error' => 'no ids'); } $ids = array(); foreach ($ids_to_check as $id) { $ids[] = (int) $id; } dbQuery('delete from products where id in (' . join(', ', $ids) . ')'); ProductsCategoriesProducts::deleteByProductId($ids); dbQuery('delete from products_relations where from_id in (' . join(', ', $ids) . ')' . ' or to_id in (' . join(', ', $ids) . ')'); dbQuery('delete from products_reviews where product_id in (' . join(', ', $ids) . ')'); Products_categoriesRecount($ids); Core_cacheClear('products_reviews,products_relations,products'); return array('ok' => 1); }
case 2: // { Create a category page dbQuery("insert into page_vars(page_id, name, value)\n\t\t\tvalues('{$pageid}', 'products_category_to_show', '{$id}')"); dbQuery("insert into page_vars(page_id, name, value)\n\t\t\tvalues('{$pageid}', 'products_product_to_show', 0)"); break; // } // } default: break; } dbQuery("insert into page_vars(page_id, name, value)\n\tvalues('{$pageid}', 'products_type_to_show', 0)"); dbQuery("insert into page_vars(page_id, name, value)\n\tvalues('{$pageid}', 'products_order_direction', 0)"); dbQuery("insert into page_vars(page_id, name, value)\n\tvalues('{$pageid}', 'products_add_a_search_box', 0)"); dbQuery("insert into page_vars(page_id, name, value)\n\tvalues('{$pageid}', 'products_per_page', 0)"); if ($what == 2) { $product = ProductsCategoriesProducts::getCategoryId($id); $product = count($product) ? $product[0] : 0; } else { $product = $id; } if ($product) { $datafields = dbOne('select data_fields from products where id=' . $product, 'data_fields'); if ($datafields) { $data = json_decode($datafields); if ($data !== false && isset($data->n)) { $firstField = $data->n; dbQuery("insert into page_vars(page_id, name, value)\n\t\t\t\tvalues('{$pageid}', 'products_order_by', '" . addslashes($firstField) . "')"); } } } if (dbOne("select name from pages where id={$pageid}", 'name') == stripslashes($name)) {
function OnlineStoreEbay_adminPublish() { list($sess, $vs, $userToken) = OnlineStoreEbay_sessionStart(); $price = (double) $_REQUEST['buy_now_price']; $bidsStartPrice = (double) $_REQUEST['bids_start_at']; $countryFrom = $vs['ebay_country_from']; $currency = 'EUR'; $dispatchDays = $vs['ebay_dispatch_days']; $productId = (int) $_REQUEST['id']; $product = Product::getInstance($productId); $description = $product->get('description'); $paypalAddress = $vs['ebay_paypal_address']; $categoryId = 0; $rs = ProductsCategoriesProducts::getByProductId($productId); foreach ($rs as $r) { $c = ProductCategory::getInstance($r); if ($c->vals['ebay_id']) { $categoryId = $c->vals['ebay_id']; break; } } $howMany = (int) $_REQUEST['quantity']; $returnsPolicy = $vs['ebay_returns_policy']; $title = $product->get('name'); $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">' . '<ErrorLanguage>en_US</ErrorLanguage><WarningLevel>High</WarningLevel>'; // { main details $xml .= '<Item>' . '<ApplicationData>{"productId":' . $productId . '}</ApplicationData>' . '<Site>Ireland</Site>' . '<Title>' . htmlspecialchars($title) . '</Title>'; // } // { price $xml .= '<Currency>' . $currency . '</Currency>'; if ($bidsStartPrice >= 0.01) { $xml .= '<BuyItNowPrice>' . sprintf('%.2f', $price) . '</BuyItNowPrice>' . '<StartPrice>' . sprintf('%.2f', $bidsStartPrice) . '</StartPrice>' . '<ListingType>Chinese</ListingType>'; } else { $xml .= '<StartPrice>' . sprintf('%.2f', $price) . '</StartPrice>' . '<ListingType>FixedPriceItem</ListingType>'; } // } // { pictures $xml .= '<PictureDetails>'; $images = $product->getAllImages(); $siteurl = isset($GLOBALS['DBVARS']['cdn']) && $GLOBALS['DBVARS']['cdn'] ? $GLOBALS['DBVARS']['cdn'] : $_SERVER['HTTP_HOST']; $xml .= '<PictureURL>' . str_replace(' ', '%20', 'http://' . $siteurl . '/f' . $product->getDefaultImage()) . '</PictureURL>'; $images_html = ''; foreach ($images as $img) { $imgUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/f' . $img; $xml .= '<PictureURL>' . str_replace(' ', '%20', $imgUrl) . '</PictureURL>'; $images_html .= '<img src="' . $imgUrl . '"/>'; } $xml .= '</PictureDetails>'; // } // { other main stuff $xml .= '<CategoryMappingAllowed>true</CategoryMappingAllowed>' . '<ConditionID>1000</ConditionID>' . '<Country>' . $countryFrom . '</Country>' . '<Location>China</Location>' . '<Description>' . htmlspecialchars($description . $images_html . '<br/><p>' . nl2br($vs['ebay_description_afterword']) . '</p>') . '</Description>' . '<DispatchTimeMax>' . $dispatchDays . '</DispatchTimeMax>' . '<PayPalEmailAddress>' . $paypalAddress . '</PayPalEmailAddress>' . '<ListingDuration>Days_30</ListingDuration>' . '<PaymentMethods>PayPal</PaymentMethods>'; // } $xml .= '<PrimaryCategory><CategoryID>' . $categoryId . '</CategoryID></PrimaryCategory>' . '<Quantity>' . $howMany . '</Quantity>' . '<ReturnPolicy><ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>' . '<ReturnsWithinOption>Days_14</ReturnsWithinOption>' . '<Description>' . htmlspecialchars($returnsPolicy) . '</Description>' . '<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>' . '</ReturnPolicy>' . '<ShippingDetails>' . '<InternationalShippingServiceOption>' . '<ShippingService>IE_SellersStandardRateInternational</ShippingService>' . '<ShippingServiceAdditionalCost currencyID="EUR">0</ShippingServiceAdditionalCost><ShippingServiceCost currencyID="EUR">0</ShippingServiceCost><ShippingServicePriority>0</ShippingServicePriority><ShipToLocation>Europe</ShipToLocation></InternationalShippingServiceOption>' . '<ShippingServiceOptions><FreeShipping>true</FreeShipping>' . '<ShippingService>IE_EconomyDeliveryFromAbroad</ShippingService>' . '<ShippingServiceAdditionalCost currencyID="EUR">0</ShippingServiceAdditionalCost>' . '</ShippingServiceOptions>' . '</ShippingDetails>' . '<ItemSpecifics>' . '<NameValueList><Name>Brand</Name><Value>Generic</Value></NameValueList>' . '<NameValueList><Name>Size</Name><Value>Free Size</Value></NameValueList>' . '</ItemSpecifics>' . '</Item>' . '<RequesterCredentials>' . '<eBayAuthToken>' . $userToken . '</eBayAuthToken>' . '</RequesterCredentials>' . '<WarningLevel>High</WarningLevel>' . '</AddItemRequest>'; $xmlstr = $sess->sendHttpRequest($xml); $reply = new SimpleXMLElement($xmlstr); $errors = isset($reply->Errors) ? $reply->Errors : false; return array('sent' => $xml, 'reply' => new SimpleXMLElement($xmlstr), 'errors' => $errors); }
static function clearCache() { self::$prodsByCid = array(); self::$catsByPid = array(); self::$activeCategories = false; Core_cacheClear('products_categories_products'); }
/** * retrieve products within a specified category * * @param int $id the product type's ID * @param string $search search string to filter by * @param array $search_arr array of search strings to filter by * @param string $sort_col field to sort by * @param string $sort_dir sort direction * @param string $location filter the products by location * * @return object instance of Products object */ static function getByCategory($id, $search = '', $search_arr = array(), $sort_col = '_name', $sort_dir = 'asc', $location = 0, $noRecurse = 0) { if (!is_numeric($id)) { return false; } $locmd5 = is_array($location) ? join(',', $location) : 0; $md5 = md5($id . '|' . $search . '|' . join(',', $search_arr) . '|' . $locmd5 . '|' . $noRecurse); if (!array_key_exists($md5, self::$instances)) { $product_ids = array(); $locFilter = $location ? ' and location in (' . $location . ')' : ''; $pids = ProductsCategoriesProducts::getByCategoryIds($id, $noRecurse); $sql = 'select id from products' . ' where enabled ' . $locFilter . ' and id in (' . join(',', $pids) . ')'; if ($search != '') { $str = str_replace(' ', '%', $search); $sql .= ' and (name like "%' . addslashes($str) . '%" or data_fields like "%' . addslashes($str) . '%")'; } $rs = dbAll($sql, false, 'products'); foreach ($rs as $r) { $product_ids[] = $r['id']; } new Products($product_ids, $md5, $search, $search_arr); $pcs = dbAll('select id,name from products_categories where parent_id=' . $id . ' and enabled order by name', false, 'products_categories'); self::$instances[$md5]->subCategories = $pcs; } return self::$instances[$md5]; }
$detail = @$pdata['stockcontrol_details']; if (!$detail) { $detail = '[]'; } echo '<table id="stockcontrol-complex"></table><script>' . 'window.stockcontrol_detail=' . $detail . ';window.stockcontrol_options=["' . join('", "', $options) . '"];</script><a href="#" id="' . 'stockcontrol-addrow">add row</a>' . '<p>' . __('To remove rows, set their options to "-- Choose --" and save the' . ' product.') . '</p>'; } // } echo '</div>'; } } // } Core_trigger('products-show-edit-form-tabs', array($pdata, $product_type)); // { categories echo '<h2>' . __('Categories') . '</h2><div id="categories"><p>' . __('At least one category must be chosen.') . '</p>'; // { add selected categories to the list $rs = ProductsCategoriesProducts::getByProductId($id); echo '<ul id="categories-wrapper">'; foreach ($rs as $r) { $cat = ProductCategory::getInstance($r); if (!$cat) { continue; } echo '<li><input type="checkbox" name="product_categories[' . $cat->vals['id'] . ']" checked="checked"/>' . $cat->getBreadcrumbs() . '</li>'; } echo '</ul><button id="category-add">Add Category</button>'; // } $cid = (int) @$pdata['default_category']; if (!$cid) { $cid = 1; } $default_category = Product::getInstance($cid)->vals['name'];