本文整理汇总了PHP中osC_Product::getWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP osC_Product::getWeight方法的具体用法?PHP osC_Product::getWeight怎么用?PHP osC_Product::getWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osC_Product
的用法示例。
在下文中一共展示了osC_Product::getWeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputCompareProductsTable
function outputCompareProductsTable()
{
global $osC_Language, $osC_Image, $osC_Weight;
$content = '';
$products_images = '';
$products_titles = '';
$products_price = '';
$products_weight = '';
$products_sku = '';
$products_manufacturers = '';
$products_desciptions = '';
$products_attributes = '';
if ($this->hasContents()) {
foreach ($this->getProducts() as $products_id) {
$osC_Product = new osC_Product($products_id);
$image = $osC_Product->getImages();
$products_images .= '<td width="120" valign="top" align="center">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image[0]['image'], $osC_Product->getTitle())) . '<br /><br />' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</td>';
$products_titles .= '<td valign="top" align="center">' . $osC_Product->getTitle() . '</td>';
$products_price .= '<td valign="top" align="center">' . $osC_Product->getPriceFormated(true) . '</td>';
$products_weight .= '<td valign="top" align="center">' . $osC_Weight->display($osC_Product->getWeight(), $osC_Product->getWeightClass()) . '</td>';
$products_sku .= '<td valign="top" align="center">' . $osC_Product->getSKU() . '</td>';
$products_manufacturers .= '<td valign="top" align="center">' . $osC_Product->getManufacturer() . '</td>';
$products_desciptions .= '<td valign="top" align="center">' . $osC_Product->getDescription() . '</td>';
if ($osC_Product->hasAttributes()) {
foreach ($osC_Product->getAttributes() as $attribute) {
$products_attributes[$attribute['name']][$products_id] = $attribute['value'];
}
}
}
$content .= '<table id="compareProducts" cellspacing="0" cellpadding="2" border="0">';
$content .= '<tr class="odd"><td width="120"> </td>' . $products_images . '</tr>';
$content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_name') . '</td>' . $products_titles . '</tr>';
$content .= '<tr class="odd"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_price') . '</td>' . $products_price . '</tr>';
$content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_weight') . '</td>' . $products_weight . '</tr>';
$content .= '<tr class="odd"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_sku') . '</td>' . $products_sku . '</tr>';
$content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_manufacturer') . '</td>' . $products_manufacturers . '</tr>';
if (!empty($products_attributes)) {
$rows = 0;
foreach ($products_attributes as $name => $attribute) {
$content .= '<tr class="' . ($rows / 2 == floor($rows / 2) ? 'odd' : 'even') . '">';
$content .= '<td valign="top" align="left" class="label">' . $name . ':</td>';
foreach ($this->getProducts() as $products_id) {
if (isset($attribute[$products_id])) {
$content .= '<td align = "center">' . $attribute[$products_id] . '</td>';
} else {
$content .= '<td align = "center"> -- </td>';
}
}
$content .= '</tr>';
$rows++;
}
}
$content .= '<tr class="' . ($rows / 2 == floor($rows / 2) ? 'odd' : 'even') . '"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_description') . '</td>' . $products_desciptions . '</tr>';
$content .= '</table></div>';
}
return $content;
}
示例2: add
//.........这里部分代码省略.........
$price = $this->_contents[$products_id_string]['price'];
} else {
$price = $osC_Product->getPrice($variants, $quantity);
if ($osC_Services->isStarted('specials')) {
global $osC_Specials;
if ($new_price = $osC_Specials->getPrice($products_id)) {
$price = $new_price;
}
}
}
$this->_contents[$products_id_string]['quantity'] = $quantity;
$this->_contents[$products_id_string]['price'] = $price;
$this->_contents[$products_id_string]['final_price'] = $price;
// update database
if ($osC_Customer->isLoggedOn()) {
$Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity, gift_certificates_data = :gift_certificates_data where customers_id = :customers_id and products_id = :products_id');
$Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
$Qupdate->bindInt(':customers_basket_quantity', $quantity);
if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
$Qupdate->bindValue(':gift_certificates_data', serialize($gift_certificates_data));
} else {
$Qupdate->bindRaw(':gift_certificates_data', 'null');
}
$Qupdate->bindInt(':customers_id', $osC_Customer->getID());
$Qupdate->bindValue(':products_id', $products_id_string);
$Qupdate->execute();
}
} else {
if (!is_numeric($quantity)) {
$quantity = 1;
}
if ($osC_Product->isGiftCertificate()) {
if ($quantity > 1) {
$quantity = 1;
$error = $osC_Language->get('error_gift_certificate_quantity_must_be_one');
}
}
//check minimum order quantity
$products_moq = $osC_Product->getMOQ();
if ($quantity < $products_moq) {
$quantity = $products_moq;
$error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq);
}
//check order increment
$increment = $osC_Product->getOrderIncrement();
if (($quantity - $products_moq) % $increment != 0) {
$quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment;
$error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment);
}
if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
$price = $gift_certificates_data['price'];
} else {
$price = $osC_Product->getPrice($variants, $quantity);
if ($osC_Services->isStarted('specials')) {
global $osC_Specials;
if ($new_price = $osC_Specials->getPrice($products_id)) {
$price = $new_price;
}
}
}
$this->_contents[$products_id_string] = array('id' => $products_id_string, 'name' => $osC_Product->getTitle(), 'type' => $osC_Product->getProductType(), 'keyword' => $osC_Product->getKeyword(), 'sku' => $osC_Product->getSKU($variants), 'image' => $osC_Product->getImage(), 'price' => $price, 'final_price' => $price, 'quantity' => $quantity, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'weight_class_id' => $osC_Product->getWeightClass(), 'gc_data' => $gift_certificates_data);
//set error to session
if (isset($error) && !empty($error)) {
$this->_contents[$products_id_string]['error'] = $error;
}
// insert into database
if ($osC_Customer->isLoggedOn()) {
$Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, gift_certificates_data, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :gift_certificates_data, now())');
$Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
$Qnew->bindInt(':customers_id', $osC_Customer->getID());
$Qnew->bindValue(':products_id', $products_id_string);
$Qnew->bindInt(':customers_basket_quantity', $quantity);
if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
$Qnew->bindValue(':gift_certificates_data', serialize($gift_certificates_data));
} else {
$Qnew->bindRaw(':gift_certificates_data', 'null');
}
$Qnew->execute();
}
if (is_array($variants) && !empty($variants)) {
foreach ($variants as $group_id => $value_id) {
$Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :language_id and pvv.language_id = :language_id');
$Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
$Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
$Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
$Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
$Qvariants->bindInt(':products_id', $osC_Product->getID());
$Qvariants->bindInt(':groups_id', $group_id);
$Qvariants->bindInt(':variants_values_id', $value_id);
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->execute();
$this->_contents[$products_id_string]['variants'][$group_id] = array('groups_id' => $group_id, 'variants_values_id' => $value_id, 'groups_name' => $Qvariants->value('products_variants_groups_name'), 'values_name' => $Qvariants->value('products_variants_values_name'));
}
}
}
$this->_cleanUp();
$this->_calculate();
}
}
示例3: outputCompareProductsTable
function outputCompareProductsTable()
{
global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies;
$content = '';
$products_images = array();
$products_titles = array();
$products_price = array();
$products_weight = array();
$products_sku = array();
$products_manufacturers = array();
$products_desciptions = array();
$products_attributes = array();
$products_variants = array();
$cols = array('<col width="20%">');
$col_width = round(80 / count($this->getProducts()));
if ($this->hasContents()) {
foreach ($this->getProducts() as $products_id) {
$cols[] = '<col width="' . $col_width . '%">';
$osC_Product = new osC_Product($products_id);
$image = $osC_Product->getImages();
$product_title = $osC_Product->getTitle();
$product_price = $osC_Product->getPriceFormated(true);
$product_weight = $osC_Product->getWeight();
$product_sku = $osC_Product->getSKU();
//if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2
$variants = array();
if ($osC_Product->hasVariants()) {
$product_variants = $osC_Product->getVariants();
if (preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)+$/', $products_id)) {
$products_variant = $product_variants[$products_id];
$variants = osc_parse_variants_from_id_string($products_id);
} else {
$products_variant = $osC_Product->getDefaultVariant();
$variants = $products_variant['groups_id'];
}
//if the product have any variants, get the group_name:value_name string
if (isset($products_variant) && isset($products_variant['groups_name']) && is_array($products_variant['groups_name']) && !empty($products_variant['groups_name'])) {
$products_variants[$products_id]['variants'] = array();
foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
$products_variants[$products_id]['variants'][] = array('name' => $groups_name, 'value' => $value_name);
}
}
$product_price = $osC_Currencies->displayPrice($osC_Product->getPrice($variants), $osC_Product->getTaxClassID());
$product_weight = $products_variant['weight'];
$product_sku = $products_variant['sku'];
$image = $products_variant['image'];
}
$image = is_array($image) ? $image[0]['image'] : $image;
$products_titles[] = $product_title;
if (!osc_empty($product_price)) {
$products_price[] = $product_price;
}
if (!osc_empty($product_weight)) {
$products_weight[] = $osC_Weight->display($product_weight, $osC_Product->getWeightClass());
}
if (!osc_empty($product_sku)) {
$products_sku[] = $product_sku;
}
if (!osc_empty($osC_Product->getManufacturer())) {
$products_manufacturers[] = $osC_Product->getManufacturer();
}
if (!osc_empty($osC_Product->getDescription())) {
$products_desciptions[] = $osC_Product->getDescription();
}
if ($osC_Product->hasAttributes()) {
foreach ($osC_Product->getAttributes() as $attribute) {
$products_attributes[$products_id]['attributes'][] = array('name' => $attribute['name'], 'value' => $attribute['value']);
}
}
$products_id = str_replace('#', '_', $products_id);
$products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&action=cart_add' . (osc_empty(osc_parse_variants_array($variants)) ? '' : '&variants=' . osc_parse_variants_array($variants))), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</div>';
}
$content .= '<table id="compareProducts" cellspacing="0" cellpadding="2" border="0">';
//add col groups
$content .= '<colgroup>';
foreach ($cols as $col) {
$content .= $col;
}
$content .= '</colgroup>';
//add product header
$content .= '<tbody>';
$content .= '<tr class="first">';
$content .= '<th> </th>';
if (!osc_empty($products_images)) {
foreach ($products_images as $k => $product_image) {
$content .= '<td' . ($k == count($products_images) - 1 ? ' class="last"' : '') . '>' . $product_image . '</td>';
}
}
$content .= '</tr>';
$content .= '</tbody>';
//add compare details
$content .= '<tbody>';
$row_class = 'even';
//add product name
if (!osc_empty($products_titles)) {
$content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_name') . '</th>';
foreach ($products_titles as $k => $product_title) {
$content .= '<td' . ($k == count($products_titles) - 1 ? ' class="last"' : '') . '>' . $product_title . '</td>';
}
$content .= '</tr>';
//.........这里部分代码省略.........
示例4: addProduct
//.........这里部分代码省略.........
$Qinsert->bindInt(':products_id', $osC_Product->getID());
$Qinsert->bindValue(':products_sku', $osC_Product->getSKU());
$Qinsert->bindValue(':products_name', $osC_Product->getTitle());
$Qinsert->bindValue(':products_price', $products_price);
$Qinsert->bindValue(':final_price', $products_price);
$Qinsert->bindValue(':products_tax', $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']));
$Qinsert->bindInt(':products_quantity', $quantity);
$Qinsert->bindInt(':products_type', $osC_Product->getProductType());
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
$orders_products_id = $osC_Database->nextID();
if (is_array($variants) && !empty($variants)) {
foreach ($variants as $groups_id => $values_id) {
$Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :language_id and pvv.language_id = :language_id');
$Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
$Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
$Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
$Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
$Qvariants->bindInt(':products_id', $osC_Product->getID());
$Qvariants->bindInt(':groups_id', $groups_id);
$Qvariants->bindInt(':variants_values_id', $values_id);
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->execute();
$Qinsert = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values) ');
$Qinsert->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
$Qinsert->bindInt(':orders_id', $this->_order_id);
$Qinsert->bindInt(':orders_products_id', $orders_products_id);
$Qinsert->bindInt(':products_variants_groups_id', $groups_id);
$Qinsert->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name'));
$Qinsert->bindInt(':products_variants_values_id', $values_id);
$Qinsert->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name'));
$Qinsert->setLogging($_SESSION['module'], $this->_order_id);
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
if ($error === false) {
if ($osC_Product->getProductType() == PRODUCT_TYPE_DOWNLOADABLE) {
$Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id');
$Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
$Qdownloadable->bindInt(':products_id', $products_id);
$Qdownloadable->execute();
$Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_filename, :download_maxdays, :download_count)');
$Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
$Qopd->bindInt(':orders_id', $_REQUEST['orders_id']);
$Qopd->bindInt(':orders_products_id', $orders_products_id);
$Qopd->bindValue(':orders_products_filename', $Qdownloadable->value('filename'));
$Qopd->bindValue(':orders_products_cache_filename', $Qdownloadable->value('cache_filename'));
$Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days'));
$Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads'));
$Qopd->setLogging($_SESSION['module'], $this->_order_id);
$Qopd->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
if ($error === false) {
if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
require_once '../includes/classes/gift_certificates.php';
$Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)');
$Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES);
$Qgc->bindInt(':orders_id', $_REQUEST['orders_id']);
$Qgc->bindInt(':gift_certificates_type', $gift_certificate_data['type']);
$Qgc->bindInt(':orders_products_id', $orders_products_id);
$Qgc->bindValue(':amount', $gift_certificate_data['price']);
$Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode());
$Qgc->bindValue(':recipients_name', $gift_certificate_data['recipients_name']);
$Qgc->bindValue(':recipients_email', $gift_certificate_data['recipients_email']);
$Qgc->bindValue(':senders_name', $gift_certificate_data['senders_name']);
$Qgc->bindValue(':senders_email', $gift_certificate_data['senders_email']);
$Qgc->bindValue(':messages', $gift_certificate_data['message']);
$Qgc->setLogging($_SESSION['module'], $this->_order_id);
$Qgc->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
}
if ($error === false) {
$this->_contents[$products_id_string] = array('id' => $products_id, 'orders_products_id' => $orders_products_id, 'quantity' => $quantity, 'name' => $osC_Product->getTitle(), 'sku' => $osC_Product->getSKU($variants_array), 'tax' => $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']), 'price' => $product_price, 'final_price' => $products_price, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'weight_class_id' => $osC_Product->getWeightClass());
}
}
osC_Product::updateStock($this->_order_id, $orders_products_id, $products_id, $quantity);
if ($error === false) {
$osC_Database->commitTransaction();
$this->_calculate();
$this->updateOrderTotal();
return true;
}
$osC_Database->rollbackTransaction();
return false;
}
示例5:
$lc_text = ' ';
if ($osC_Product->hasManufacturer()) {
$lc_text = ' ' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $osC_Product->getManufacturerID()), $osC_Product->getManufacturer()) . ' ';
}
break;
case 'PRODUCT_LIST_PRICE':
$lc_align = 'right';
$lc_text = ' ' . $osC_Product->getPriceFormated() . ' ';
break;
case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text = ' ' . $osC_Product->getQuantity() . ' ';
break;
case 'PRODUCT_LIST_WEIGHT':
$lc_align = 'right';
$lc_text = ' ' . $osC_Product->getWeight() . ' ';
break;
case 'PRODUCT_LIST_IMAGE':
$lc_align = 'center';
if (isset($_GET['manufacturers'])) {
$lc_text = osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword() . '&manufacturers=' . $_GET['manufacturers']), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle()));
} else {
$lc_text = ' ' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword() . ($cPath ? '&cPath=' . $cPath : '')), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle())) . ' ';
}
break;
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text = osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $osC_Product->getKeyword() . '&' . osc_get_all_get_params(array('action')) . '&action=cart_add'), osc_draw_image_button('button_buy_now.gif', $osC_Language->get('button_buy_now'))) . ' ';
break;
}
echo ' <td ' . (empty($lc_align) === false ? 'align="' . $lc_align . '" ' : '') . 'class="productListing-data">' . $lc_text . '</td>' . "\n";
示例6: output_compare_products_table
function output_compare_products_table()
{
global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies, $toC_Compare_Products, $osC_Services;
$content = '';
$products_images = array();
$products_titles = array();
$products_price = array();
$products_weight = array();
$products_sku = array();
$products_manufacturers = array();
$products_desciptions = array();
$products_attributes = array();
$products_variants = array();
$cols = array('<col width="20%">');
$col_width = round(80 / count($toC_Compare_Products->getProducts()));
if ($toC_Compare_Products->hasContents()) {
foreach ($toC_Compare_Products->getProducts() as $products_id_string) {
$cols[] = '<col width="' . $col_width . '%">';
$osC_Product = new osC_Product($products_id_string);
$products_id = osc_get_product_id($products_id_string);
$image = $osC_Product->getImages();
$product_title = $osC_Product->getTitle();
$product_price = $osC_Product->getPriceFormated(true);
$product_weight = $osC_Product->getWeight();
$product_sku = $osC_Product->getSKU();
//if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2
$variants = array();
if ($osC_Product->hasVariants()) {
$product_variants = $osC_Product->getVariants();
if (preg_match('/^[0-9]+(?:#?(?:[0-9]+:?[0-9]+)+(?:;?([0-9]+:?[0-9]+)+)*)+$/', $products_id_string)) {
$products_variant = $product_variants[$products_id_string];
$variants = osc_parse_variants_from_id_string($products_id_string);
} else {
$products_variant = $osC_Product->getDefaultVariant();
$variants = $products_variant['groups_id'];
}
//if the product have any variants, get the group_name:value_name string
if (isset($products_variant) && isset($products_variant['groups_name']) && is_array($products_variant['groups_name']) && !empty($products_variant['groups_name'])) {
$products_variants[$products_id_string]['variants'] = array();
foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
$products_variants[$products_id_string]['variants'][] = array('name' => $groups_name, 'value' => $value_name);
}
}
$product_price = $osC_Currencies->displayPrice($osC_Product->getPrice($variants), $osC_Product->getTaxClassID());
$product_weight = $products_variant['weight'];
$product_sku = $products_variant['sku'];
$image = $products_variant['image'];
}
$image = is_array($image) ? $image[0]['image'] : $image;
$products_titles[] = $product_title;
if (!osc_empty($product_price)) {
$products_price[] = $product_price;
}
if (!osc_empty($product_weight)) {
$products_weight[] = $osC_Weight->display($product_weight, $osC_Product->getWeightClass());
}
if (!osc_empty($product_sku)) {
$products_sku[] = $product_sku;
}
if (!osc_empty($osC_Product->getManufacturer())) {
$products_manufacturers[] = $osC_Product->getManufacturer();
}
if (!osc_empty($osC_Product->getDescription())) {
$products_desciptions[] = $osC_Product->getDescription();
}
if ($osC_Product->hasAttributes()) {
foreach ($osC_Product->getAttributes() as $attribute) {
$products_attributes[$products_id]['attributes'][] = array('name' => $attribute['name'], 'value' => $attribute['value']);
}
}
$products_id_string = str_replace('#', '_', $products_id_string);
//used to fix bug [#209 - Compare / wishlist variant problem]
if (isset($osC_Services) && $osC_Services->isStarted('sefu') && count($variants) > 0) {
$products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&pid=' . $products_id_string . '&action=cart_add'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</div>';
} else {
$products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id_string . '&action=cart_add'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</div>';
}
}
$content .= '<table class="table table-hover table-striped">';
//add col groups
$content .= '<colgroup>';
foreach ($cols as $col) {
$content .= $col;
}
$content .= '</colgroup>';
//add product header
$content .= '<tbody>';
$content .= '<tr class="first">';
$content .= '<th> </th>';
if (!osc_empty($products_images)) {
foreach ($products_images as $k => $product_image) {
$content .= '<td' . ($k == count($products_images) - 1 ? ' class="last"' : '') . '>' . $product_image . '</td>';
}
}
$content .= '</tr>';
$content .= '</tbody>';
//add compare details
$content .= '<tbody>';
$row_class = 'even';
//add product name
//.........这里部分代码省略.........