function show_ecwid_catalog($ecwid_store_id) { include_once "ecwid_product_api.php"; $ecwid_store_id = intval($ecwid_store_id); $api = new EcwidProductApi($ecwid_store_id); $cat_id = isset($_GET['ecwid_category_id']) ? intval($_GET['ecwid_category_id']) : false; $prod_id = isset($_GET['ecwid_product_id']) ? intval($_GET['ecwid_product_id']) : false; $ecwid_category_id = $cat_id; $ecwid_product_id = $prod_id; if (!empty($ecwid_product_id)) { $params = array(array("alias" => "p", "action" => "product", "params" => array("id" => $ecwid_product_id)), array("alias" => "pf", "action" => "profile")); $batch_result = $api->get_batch_request($params); $product = $batch_result["p"]; $profile = $batch_result["pf"]; } else { if (empty($ecwid_category_id)) { $ecwid_category_id = 0; } $params = array(array("alias" => "c", "action" => "categories", "params" => array("parent" => $ecwid_category_id)), array("alias" => "p", "action" => "products", "params" => array("category" => $ecwid_category_id)), array("alias" => "pf", "action" => "profile")); $batch_result = $api->get_batch_request($params); $categories = $batch_result["c"]; $products = $batch_result["p"]; $profile = $batch_result["pf"]; } $html = ''; if (isset($product) && is_array($product)) { $html = "<div class='hproduct'>"; $html .= "<div class='ecwid_catalog_product_image photo'><img src='" . $product["thumbnailUrl"] . "'/></div>"; $html .= "<div class='ecwid_catalog_product_name fn'>" . htmlentities($product["name"]) . "</div>"; $html .= "<div class='ecwid_catalog_product_price price'>Price: " . $product["price"] . " " . $profile["currency"] . "</div>"; $html .= "<div class='ecwid_catalog_product_description description'>" . $product["description"] . "</div>"; $html .= "</div>"; } else { if (is_array($categories)) { foreach ($categories as $category) { $category_url = ecwid_internal_construct_url($category["url"], array("ecwid_category_id" => $category["id"])); $category_name = $category["name"]; $html .= "<div class='ecwid_catalog_category_name'><a href='" . $category_url . "'>" . $category_name . "</a><br /></div>"; } } if (is_array($products)) { foreach ($products as $product) { $product_url = ecwid_internal_construct_url($product["url"], array("ecwid_product_id" => $product["id"])); $product_name = $product["name"]; $product_price = $product["price"] . " " . $profile["currency"]; $html .= "<div>"; $html .= "<span class='ecwid_product_name'><a href='" . $product_url . "'>" . $product_name . "</a></span>"; $html .= " <span class='ecwid_product_price'>" . $product_price . "</span>"; $html .= "</div>"; } } } return $html; }
function show_ecwid_catalog($ecwid_store_id) { include_once "ecwid_product_api.php"; $ecwid_store_id = intval($ecwid_store_id); $api = new EcwidProductApi($ecwid_store_id); global $wp_query; $ecwid_category_id = intval($wp_query->query_vars['ecwid_category_id']); $ecwid_product_id = intval($wp_query->query_vars['ecwid_product_id']); static $ecwid_cat_prod_data; if (empty($ecwid_cat_prod_data)) { $ecwid_cat_prod_data = ecwid_get_mixed_data(); } if (!empty($ecwid_product_id)) { $product = $ecwid_cat_prod_data["p"]; } else { $categories = $ecwid_cat_prod_data["c"]; $products = $ecwid_cat_prod_data["p"]; } $profile = $ecwid_cat_prod_data["pf"]; $html = ''; if (is_array($product)) { $html = "<div class='hproduct'>"; $html .= "<h2 class='ecwid_catalog_product_name fn'>" . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "</h2>"; if (!empty($product['thumbnailUrl'])) { $html .= "<div class='ecwid_catalog_product_image photo'><img src='" . $product["thumbnailUrl"] . "' alt='" . htmlentities($product["sku"], ENT_COMPAT, 'UTF-8') . " " . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "'/></div>"; } $html .= "<div class='ecwid_catalog_product_price price'>Price: " . $product["price"] . " " . $profile["currency"] . "</div>"; $html .= "<div class='ecwid_catalog_product_description description'>" . $product["description"] . "</div>"; $html .= "</div>"; } else { if (is_array($categories)) { foreach ($categories as $category) { $category_url = ecwid_internal_construct_url($category["url"], array("ecwid_category_id" => $category["id"]), $api); $category_name = $category["name"]; $html .= "<div class='ecwid_catalog_category_name'><a href='" . htmlspecialchars($category_url) . "'>" . $category_name . "</a><br /></div>"; } } if (is_array($products)) { foreach ($products as $product) { $product_url = ecwid_internal_construct_url($product["url"], array("ecwid_product_id" => $product["id"]), $api); $product_name = $product["name"]; $product_price = $product["price"] . " " . $profile["currency"]; $html .= "<div>"; $html .= "<span class='ecwid_product_name'><a href='" . htmlspecialchars($product_url) . "'>" . $product_name . "</a></span>"; $html .= " <span class='ecwid_product_price'>" . $product_price . "</span>"; $html .= "</div>"; } } } return $html; }