/**
  * Test sale price.
  */
 public function testSalePrice()
 {
     foreach ($this->get('productService')->getAllProducts(false, 1) as $product) {
         $offers = $product->getOffers();
         // without tax
         $this->assertEquals(zen_get_products_special_price($product->getId(), false), $offers->getSalePrice(false), '%s productId=' . $product->getId());
     }
 }
Example #2
0
function zen_get_products_display_price_pure_green($products_id)
{
    global $db, $currencies;
    $free_tag = "";
    $call_tag = "";
    // 0 = normal shopping
    // 1 = Login to shop
    // 2 = Can browse but no prices
    // verify display of prices
    switch (true) {
        case CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == '':
            // customer must be logged in to browse
            return '';
            break;
        case CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '':
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE;
            break;
        case CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != '':
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
            break;
        case CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3' and $_SESSION['customer_id'] == '':
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
        case CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3' and $_SESSION['customers_authorization'] > '0':
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
        default:
            // proceed normally
            break;
    }
    // show case only
    if (STORE_STATUS != '0') {
        if (STORE_STATUS == '1') {
            return '';
        }
    }
    // $new_fields = ', product_is_free, product_is_call, product_is_showroom_only';
    $product_check = $db->Execute("select products_tax_class_id, products_price, products_priced_by_attribute, product_is_free, product_is_call, products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'" . " limit 1");
    // no prices on Document General
    if ($product_check->fields['products_type'] == 3) {
        return '';
    }
    $show_display_price = '';
    $display_normal_price = zen_get_products_base_price($products_id);
    $display_special_price = zen_get_products_special_price($products_id, true);
    $display_sale_price = zen_get_products_special_price($products_id, false);
    $show_sale_discount = '';
    if (SHOW_SALE_DISCOUNT_STATUS == '1' and ($display_special_price != 0 or $display_sale_price != 0)) {
        if ($display_sale_price) {
            if (SHOW_SALE_DISCOUNT == 1) {
                if ($display_normal_price != 0) {
                    $show_discount_amount = number_format(100 - $display_sale_price / $display_normal_price * 100, SHOW_SALE_DISCOUNT_DECIMALS);
                } else {
                    $show_discount_amount = '';
                }
                $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $show_discount_amount . PRODUCT_PRICE_DISCOUNT_PERCENTAGE . '</span>';
            } else {
                $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $currencies->display_price($display_normal_price - $display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT . '</span>';
            }
        } else {
            if (SHOW_SALE_DISCOUNT == 1) {
                $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . number_format(100 - $display_special_price / $display_normal_price * 100, SHOW_SALE_DISCOUNT_DECIMALS) . PRODUCT_PRICE_DISCOUNT_PERCENTAGE . '</span>';
            } else {
                $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $currencies->display_price($display_normal_price - $display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT . '</span>';
            }
        }
    }
    if ($display_special_price) {
        if ($product_check->fields['product_is_free'] == '1' or $product_check->fields['product_is_call'] == '1') {
        } else {
            $show_normal_price = '<span class="normalprice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . ' </span>';
        }
        if ($display_sale_price && $display_sale_price != $display_special_price) {
            //$show_special_price = '&nbsp;' . '<span class="productSpecialPriceSale">' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            if ($product_check->fields['product_is_free'] == '1') {
                // $show_sale_price = '<br />' . '<span class="productSalePrice">' . PRODUCT_PRICE_SALE . '<s>' . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>' . '</span>';
            } else {
                $show_sale_price = '' . '<span class="productSalePrice">' . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            }
        } else {
            if ($product_check->fields['product_is_free'] == '1') {
                //$show_special_price = '&nbsp;' . '<span class="productSpecialPrice">' . '<s>' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>' . '</span>';
            } else {
                $show_special_price = '&nbsp;' . '<span class="productSpecialPrice">' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            }
            $show_sale_price = '';
        }
    } else {
        if ($display_sale_price) {
            $show_normal_price = '<span class="normalprice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . ' </span>';
            $show_special_price = '';
            $show_sale_price = '<span class="productSalePrice">' . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
        } else {
            if ($product_check->fields['product_is_free'] == '1') {
                //$show_normal_price = '<s>' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>';
            } else {
                $show_normal_price = '<span class="central-boxes-price">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            }
            $show_special_price = '';
            $show_sale_price = '';
        }
    }
    if ($display_normal_price == 0) {
        // don't show the $0.00
        $final_display_price = $show_special_price . $show_sale_price . $show_sale_discount;
    } else {
        $final_display_price = $show_normal_price . $show_special_price . $show_sale_price . $show_sale_discount;
    }
    // If Free, Show it
    if ($product_check->fields['product_is_free'] == '1') {
        if (OTHER_IMAGE_PRICE_IS_FREE_ON == '0') {
            $free_tag = '<span class="free">' . PRODUCTS_PRICE_IS_FREE_TEXT . '</span>';
        } else {
            $free_tag = zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_PRICE_IS_FREE, PRODUCTS_PRICE_IS_FREE_TEXT);
        }
    }
    // If Call for Price, Show it
    if ($product_check->fields['product_is_call']) {
        if (PRODUCTS_PRICE_IS_CALL_IMAGE_ON == '0') {
            $call_tag = '<span class="call-for-price">' . PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT . '</span>';
        } else {
            $call_tag = zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_CALL_FOR_PRICE, PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT);
        }
    }
    return $final_display_price . $free_tag . $call_tag;
}
Example #3
0
 /**
  * Method to return details of all products in the cart
  *
  * @param boolean whether to check if cart contents are valid
  * @return array
  */
 public function get_products($check_for_valid_cart = false)
 {
     $this->notify('NOTIFIER_CART_GET_PRODUCTS_START');
     if (!is_array($this->contents)) {
         return false;
     }
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $products_query = "select p.products_id, p.master_categories_id, p.products_status, pd.products_name, p.products_model, p.products_image,\n                p.products_price, p.products_weight, p.products_tax_class_id,\n                p.products_quantity_order_min, p.products_quantity_order_units, p.products_quantity_order_max,\n                p.product_is_free, p.products_priced_by_attribute,\n                p.products_discount_type, p.products_discount_type_from\n                from %table.products% p, %table.products_description% pd\n                where p.products_id = '" . (int) $products_id . "'\n                and pd.products_id = p.products_id\n                and pd.language_id = '" . (int) $this->getSessionVar('languages_id') . "'";
         if ($products = $this->getDb()->Execute($products_query)) {
             $prid = $products->fields['products_id'];
             $products_price = $products->fields['products_price'];
             //fix here
             /*
                     $special_price = zen_get_products_special_price($prid);
                     if ($special_price) {
                     $products_price = $special_price;
                     }
             */
             $special_price = zen_get_products_special_price($prid);
             if ($special_price and $products->fields['products_priced_by_attribute'] == 0) {
                 $products_price = $special_price;
             } else {
                 $special_price = 0;
             }
             if (zen_get_products_price_is_free($products->fields['products_id'])) {
                 // no charge
                 $products_price = 0;
             }
             // adjust price for discounts when priced by attribute
             if ($products->fields['products_priced_by_attribute'] == '1' and zen_has_product_attributes($products->fields['products_id'], 'false')) {
                 if ($special_price) {
                     $products_price = $special_price;
                 } else {
                     $products_price = $products->fields['products_price'];
                 }
             } else {
                 // discount qty pricing
                 if ($products->fields['products_discount_type'] != '0') {
                     $products_price = zen_get_products_discount_price_qty($products->fields['products_id'], $this->contents[$products_id]['qty']);
                 }
             }
             // validate cart contents for checkout
             if ($check_for_valid_cart == true) {
                 $fix_once = 0;
                 // Check products_status if not already
                 $check_status = $products->fields['products_status'];
                 if ($check_status == 0) {
                     $fix_once++;
                     $this->setSessionVar('valid_to_checkout', false);
                     $cart_errors = $this->getSessionVar('cart_errors');
                     $cart_errors .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_STATUS_SHOPPING_CART . '<br />';
                     $this->setSessionVar('cart_errors', $cart_errors);
                     $this->remove($products_id);
                 } else {
                     if (isset($this->contents[$products_id]['attributes'])) {
                         reset($this->contents[$products_id]['attributes']);
                         $chkcount = 0;
                         while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
                             $chkcount++;
                             $chk_attributes_exist_query = "select products_id\n                                    from %table.products_attributes% pa\n                                    where pa.products_id = '" . (int) $products_id . "'\n                                    and pa.options_values_id = '" . (int) $value . "'";
                             $chk_attributes_exist = $this->getDb()->Execute($chk_attributes_exist_query);
                             if ($chk_attributes_exist->EOF) {
                                 $fix_once++;
                                 $this->setSessionVar('valid_to_checkout', false);
                                 $cart_errors = $this->getSessionVar('cart_errors');
                                 $cart_errors .= ERROR_PRODUCT_ATTRIBUTES . $products->fields['products_name'] . ERROR_PRODUCT_STATUS_SHOPPING_CART_ATTRIBUTES . '<br />';
                                 $this->setSessionVar('cart_errors', $cart_errors);
                                 $this->remove($products_id);
                                 break;
                             }
                         }
                     }
                 }
                 // check only if valid products_status
                 if ($fix_once == 0) {
                     $check_quantity = $this->contents[$products_id]['qty'];
                     $check_quantity_min = $products->fields['products_quantity_order_min'];
                     // Check quantity min
                     if ($new_check_quantity = $this->in_cart_mixed($prid)) {
                         $check_quantity = $new_check_quantity;
                     }
                 }
                 // Check Quantity Max if not already an error on Minimum
                 if ($fix_once == 0) {
                     if ($products->fields['products_quantity_order_max'] != 0 && $check_quantity > $products->fields['products_quantity_order_max']) {
                         $fix_once++;
                         $this->setSessionVar('valid_to_checkout', false);
                         $cart_errors = $this->getSessionVar('cart_errors');
                         $cart_errors .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_MAX_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int) $prid, false, true) . '</span> ' . '<br />';
                         $this->setSessionVar('cart_errors', $cart_errors);
                     }
                 }
                 if ($fix_once == 0) {
                     if ($check_quantity < $check_quantity_min) {
                         $fix_once++;
                         $this->setSessionVar('valid_to_checkout', false);
                         $cart_errors = $this->getSessionVar('cart_errors');
                         $cart_errors .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_MIN_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int) $prid, false, true) . '</span> ' . '<br />';
                         $this->setSessionVar('cart_errors', $cart_errors);
                     }
                 }
                 // Check Quantity Units if not already an error on Quantity Minimum
                 if ($fix_once == 0) {
                     $check_units = $products->fields['products_quantity_order_units'];
                     if (fmod_round($check_quantity, $check_units) != 0) {
                         $this->setSessionVar('valid_to_checkout', false);
                         $cart_errors = $this->getSessionVar('cart_errors');
                         $cart_errors .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int) $prid, false, true) . '</span> ' . '<br />';
                         $this->setSessionVar('cart_errors', $cart_errors);
                     }
                 }
                 // Verify Valid Attributes
             }
             //clr 030714 update $products_array to include attribute value_text. This is needed for text attributes.
             // convert quantity to proper decimals
             if (QUANTITY_DECIMALS != 0) {
                 $fix_qty = $this->contents[$products_id]['qty'];
                 switch (true) {
                     case !strstr($fix_qty, '.'):
                         $new_qty = $fix_qty;
                         break;
                     default:
                         $new_qty = preg_replace('/[0]+$/', '', $this->contents[$products_id]['qty']);
                         break;
                 }
             } else {
                 $new_qty = $this->contents[$products_id]['qty'];
             }
             $check_unit_decimals = zen_get_products_quantity_order_units((int) $products->fields['products_id']);
             if (strstr($check_unit_decimals, '.')) {
                 $new_qty = round($new_qty, QUANTITY_DECIMALS);
             } else {
                 $new_qty = round($new_qty, 0);
             }
             if ($new_qty == (int) $new_qty) {
                 $new_qty = (int) $new_qty;
             }
             $products_array[] = array('id' => $products_id, 'category' => $products->fields['master_categories_id'], 'name' => $products->fields['products_name'], 'model' => $products->fields['products_model'], 'image' => $products->fields['products_image'], 'price' => $products->fields['product_is_free'] == '1' ? 0 : $products_price, 'quantity' => $new_qty, 'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id), 'final_price' => $products_price + $this->attributes_price($products_id), 'onetime_charges' => $this->attributes_price_onetime_charges($products_id, $new_qty), 'tax_class_id' => $products->fields['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '', 'attributes_values' => isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : '', 'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'], 'product_is_free' => $products->fields['product_is_free'], 'products_discount_type' => $products->fields['products_discount_type'], 'products_discount_type_from' => $products->fields['products_discount_type_from']);
         }
     }
     $this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
     return $products_array;
 }
Example #4
0
             // 						}
             // 				}
             // 				$images = array_unique($images);
             $property = getProperty($products->fields['products_id'], $lang_id, true);
             $str_py = '';
             foreach ($property as $k => $o) {
                 $str_py .= '<ul>';
                 $str_py .= '<li>' . $k . '<ul>';
                 foreach ($o as $v) {
                     $str_py .= $v;
                 }
                 $str_py .= '</ul></li>';
                 $str_py .= '</ul>';
             }
             $description .= $str_py;
             $description .= $currencies->format(zen_get_products_special_price($products->fields['products_id'], true));
             $description .= sprintf('{{%s:%s}}', $host, $products->fields['products_id']);
             $wp_category = array();
             foreach ($categores as $c) {
                 if (!empty($c['name'])) {
                     $wp_category[] = $c['name'];
                 }
             }
             $wp_category = implode('>', $wp_category);
             $fields = array($products->fields['products_name'] . ' ' . $products->fields['products_model'], $description, $wp_category, str_replace('>', ',', $wp_category), "", "", "", "");
             break;
     }
     $str = '"' . implode('","', $fields) . "\"\n";
     fwrite($handle, $str);
     $products->MoveNext();
 }
Example #5
0
    $products_image_name = $pInfo->products_image;
}
$form_action = isset($_GET['pID']) ? 'update_product' : 'insert_product';
echo zen_draw_form($form_action, $type_admin_handler, 'cPath=' . $cPath . (isset($_GET['product_type']) ? '&product_type=' . $_GET['product_type'] : '') . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=' . $form_action . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'post', 'enctype="multipart/form-data"');
$languages = zen_get_languages();
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
    if (isset($_GET['read']) && $_GET['read'] == 'only') {
        $pInfo->products_name = zen_get_products_name($pInfo->products_id, $languages[$i]['id']);
        $pInfo->products_description = zen_get_products_description($pInfo->products_id, $languages[$i]['id']);
        $pInfo->products_url = zen_get_products_url($pInfo->products_id, $languages[$i]['id']);
    } else {
        $pInfo->products_name = zen_db_prepare_input($products_name[$languages[$i]['id']]);
        $pInfo->products_description = zen_db_prepare_input($products_description[$languages[$i]['id']]);
        $pInfo->products_url = zen_db_prepare_input($products_url[$languages[$i]['id']]);
    }
    $specials_price = zen_get_products_special_price($pID);
    ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php 
    echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $pInfo->products_name;
    ?>
</td>
            <td class="pageHeading" align="right"><?php 
    echo $currencies->format($pInfo->products_price) . ($pInfo->products_virtual == 1 ? '<span class="errorText">' . '<br />' . TEXT_VIRTUAL_PREVIEW . '</span>' : '') . ($pInfo->product_is_always_free_shipping == 1 ? '<span class="errorText">' . '<br />' . TEXT_FREE_SHIPPING_PREVIEW . '</span>' : '') . ($pInfo->products_priced_by_attribute == 1 ? '<span class="errorText">' . '<br />' . TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES_PREVIEW . '</span>' : '') . ($pInfo->product_is_free == 1 ? '<span class="errorText">' . '<br />' . TEXT_PRODUCTS_IS_FREE_PREVIEW . '</span>' : '') . ($pInfo->product_is_call == 1 ? '<span class="errorText">' . '<br />' . TEXT_PRODUCTS_IS_CALL_PREVIEW . '</span>' : '') . ($pInfo->products_qty_box_status == 0 ? '<span class="errorText">' . '<br />' . TEXT_PRODUCTS_QTY_BOX_STATUS_PREVIEW . '</span>' : '') . ($pInfo->products_priced_by_attribute == 1 ? '<br />' . zen_get_products_display_price($_GET['pID']) : '');
    ?>
</td>
          </tr>
        </table></td>
 function importProduct($data, $format)
 {
     // prepare data
     $validate = true;
     $ignore_column = $this->getFormatColumnIgnore($format['csv_format_type_id']);
     $ignore_id = $ignore_column['csv_column_id'];
     $delete_column = $this->getFormatColumnDelete($format['csv_format_type_id']);
     $delete_id = $delete_column['csv_column_id'];
     $this->messageStack->reset();
     // search products_model and validate
     foreach ($format['columns'] as $key => $val) {
         if (!empty($val['csv_column_validate_function'])) {
             $validate_function = $val['csv_column_validate_function'];
             if ($this->{$validate_function}($data[$key], $val['csv_column_name']) === true) {
                 $validate = $validate && true;
             } else {
                 $validate = $validate && false;
             }
         }
         if ($val['csv_columns_dbtable'] == 'products' && $val['csv_columns_dbcolumn'] == 'products_model') {
             $products_model = $data[$key];
         }
         if ($val['csv_column_id'] == $delete_id) {
             if ($data[$key] == 1) {
                 $delete_flag = true;
             } else {
                 $delete_flag = false;
             }
         }
     }
     if (empty($products_model)) {
         $validate = $validate && false;
         $this->messageStack->add(PRODUCT_CSV_MESSAGE_NO_MODEL, 'warning');
     }
     // return if validate is false
     if ($validate === false) {
         return false;
     }
     // main
     $sql = 'SELECT * FROM ' . TABLE_PRODUCTS . ' WHERE products_model=\'' . zen_db_input($products_model) . '\'';
     $product = $this->db->Execute($sql);
     if ($product->RecordCount() == 0) {
         $sql = 'INSERT INTO ' . TABLE_PRODUCTS . ' (products_model, products_date_added, products_status) VALUES(\'' . zen_db_input($products_model) . '\', NOW(), 1)';
         $this->db->Execute($sql);
         $products_id = $this->db->Insert_ID();
         // search language id
         foreach ($format['columns'] as $val) {
             if (isset($val['language_id'])) {
                 $language_ids[$val['language_id']] = 1;
             }
         }
         // insert products description
         foreach ($language_ids as $language_id => $flag) {
             $sql = 'INSERT INTO ' . TABLE_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $language_id . '\')';
             $this->db->Execute($sql);
             $sql = 'INSERT INTO ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $language_id . '\')';
             $this->db->Execute($sql);
         }
     } else {
         $products_id = $product->fields['products_id'];
     }
     // delete product
     if ($delete_flag === true) {
         zen_remove_product($products_id);
         $this->messageStack->add(PRODUCT_CSV_MESSAGE_DELETE, 'success');
         return true;
     }
     foreach ($format['columns'] as $key => $val) {
         if ($val['csv_column_id'] == $ignore_id) {
             continue;
         }
         if ($val['csv_columns_dbtable'] == 'products') {
             if ($val['csv_columns_dbcolumn'] == 'products_status' && $data[$key] == '') {
                 continue;
             }
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
             if ($val['csv_columns_dbcolumn'] == 'products_price') {
                 $products_price = $data[$key];
             }
         } elseif ($val['csv_columns_dbtable'] == 'tax_class') {
             $sql = 'SELECT tax_class_id FROM ' . TABLE_TAX_CLASS . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $tax_class = $this->db->Execute($sql);
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_tax_class_id=\'' . $tax_class->fields['tax_class_id'] . '\' WHERE products_id=\'' . $products_id . '\'';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'product_types') {
             $sql = 'SELECT type_id FROM ' . TABLE_PRODUCT_TYPES . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $product_type = $this->db->Execute($sql);
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_type=\'' . $product_type->fields['type_id'] . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'manufacturers') {
             $sql = 'SELECT manufacturers_id FROM ' . TABLE_MANUFACTURERS . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $manufacturer = $this->db->Execute($sql);
             if ($manufacturer->RecordCount() == 0) {
                 // insert manufacturer
                 $sql = 'INSERT INTO ' . TABLE_MANUFACTURERS . ' (manufacturers_name, date_added, last_modified) VALUES (\'' . zen_db_input($data[$key]) . '\', NOW(), NOW())';
                 $this->db->Execute($sql);
                 $manufacturer_id = $this->db->Insert_ID();
             } else {
                 $manufacturer_id = $manufacturer->fields['manufacturers_id'];
             }
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET manufacturers_id=\'' . $manufacturer_id . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'products_description') {
             if (isset($val['language_id'])) {
                 $sql = 'UPDATE ' . TABLE_PRODUCTS_DESCRIPTION . ' SET ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\' WHERE products_id=' . $products_id . ' AND language_id=' . $val['language_id'] . '';
                 $this->db->Execute($sql);
             }
         } elseif ($val['csv_columns_dbtable'] == 'meta_tags_products_description') {
             if (isset($val['language_id'])) {
                 $meta_tags[$val['language_id']][$val['csv_columns_dbcolumn']] = $data[$key];
             }
         } elseif ($val['csv_columns_dbtable'] == 'featured') {
             $featured[$val['csv_columns_dbcolumn']] = $data[$key];
         } elseif ($val['csv_columns_dbtable'] == 'specials') {
             $specials[$val['csv_columns_dbcolumn']] = $data[$key];
         }
     }
     if (isset($meta_tags)) {
         foreach ($meta_tags as $key => $val) {
             if (!empty($val['metatags_title']) || !empty($val['metatags_keywords']) || !empty($val['metatags_description'])) {
                 // set metatags
                 $sql = 'SELECT * FROM ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $meta_tags_record = $this->db->Execute($sql);
                 if ($meta_tags_record->RecordCount() == 0) {
                     $sql = 'INSERT INTO ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $key . '\')';
                     $this->db->Execute($sql);
                 }
                 $sql = 'UPDATE ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' SET metatags_title=\'' . zen_db_input($val['metatags_title']) . '\', metatags_keywords=\'' . zen_db_input($val['metatags_keywords']) . '\', metatags_description=\'' . zen_db_input($val['metatags_description']) . '\' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $this->db->Execute($sql);
             } else {
                 // delete metatags
                 $sql = 'DELETE FROM ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $this->db->Execute($sql);
             }
         }
     }
     if (isset($featured)) {
         if (!empty($featured['featured_date_available']) || !empty($featured['expires_date'])) {
             // set featured
             $sql = 'SELECT * FROM ' . TABLE_FEATURED . ' WHERE products_id=' . $products_id . '';
             $featured_record = $this->db->Execute($sql);
             if ($featured_record->RecordCount() == 0) {
                 $sql = 'INSERT INTO ' . TABLE_FEATURED . ' (products_id) VALUES (\'' . $products_id . '\')';
                 $this->db->Execute($sql);
             }
             $sql = 'UPDATE ' . TABLE_FEATURED . ' SET featured_date_available=\'' . zen_db_input($featured['featured_date_available']) . '\', expires_date=\'' . zen_db_input($featured['expires_date']) . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } else {
             // delete featured
             $sql = 'DELETE FROM ' . TABLE_FEATURED . ' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         }
     }
     if (isset($specials)) {
         if (!empty($specials['specials_new_products_price'])) {
             // prepare data
             $status = 1;
             if (!isset($specials['specials_date_available']) || empty($specials['specials_date_available'])) {
                 $specials['specials_date_available'] = '0001-01-01';
                 $status = $status * 1;
             } else {
                 $available_time = strtotime($specials['specials_date_available']);
                 if ($available_time !== false && $available_time <= time()) {
                     $status = $status * 1;
                 } else {
                     $status = $status * 0;
                 }
             }
             if (!isset($specials['expires_date']) || empty($specials['expires_date'])) {
                 $specials['expires_date'] = '0001-01-01';
                 $status = $status * 1;
             } else {
                 $expire_time = strtotime($specials['expires_date']);
                 if ($expire_time !== false && $expire_time >= time()) {
                     $status = $status * 1;
                 } else {
                     $status = $status * 0;
                 }
             }
             // set specials
             $sql = 'SELECT * FROM ' . TABLE_SPECIALS . ' WHERE products_id=' . $products_id . '';
             $specials_record = $this->db->Execute($sql);
             if ($specials_record->RecordCount() == 0) {
                 $sql = 'INSERT INTO ' . TABLE_SPECIALS . ' (products_id, specials_date_added, specials_last_modified) VALUES (\'' . $products_id . '\', NOW(), NOW())';
                 $this->db->Execute($sql);
             }
             $sql = 'UPDATE ' . TABLE_SPECIALS . ' SET specials_new_products_price=\'' . zen_db_input($specials['specials_new_products_price']) . '\', expires_date=\'' . zen_db_input($specials['expires_date']) . '\', specials_date_available=\'' . zen_db_input($specials['specials_date_available']) . '\', status=' . $status . ', date_status_change=NOW(), specials_last_modified=NOW() WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } else {
             // delete specials
             $sql = 'DELETE FROM ' . TABLE_SPECIALS . ' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         }
     }
     // update products_price_sorter
     $special_price = zen_get_products_special_price($products_id);
     $products_price = isset($products_price) ? $products_price : 0;
     $products_price_sorter = $special_price === false ? $products_price : $special_price;
     $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_price_sorter=\'' . zen_db_input($products_price_sorter) . '\' WHERE products_id=' . $products_id;
     $this->db->Execute($sql);
     $this->messageStack->add(PRODUCT_CSV_MESSAGE_SUCCESS, 'success');
     return true;
 }
 /**
  * Method to calculate the content type of a cart
  *
  * @param boolean whether to test for Gift Vouchers only
  * @return string
  */
 function get_content_type($gv_only = 'false')
 {
     global $db;
     $this->content_type = false;
     $gift_voucher = 0;
     //      if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
     if ($this->count_contents() > 0) {
         reset($this->contents);
         while (list($products_id, ) = each($this->contents)) {
             $free_ship_check = $db->Execute("select products_virtual, products_model, products_price, product_is_always_free_shipping from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($products_id) . "'");
             $virtual_check = false;
             if (preg_match('/^GIFT/', addslashes($free_ship_check->fields['products_model']))) {
                 // @TODO - fix GIFT price in cart special/attribute
                 $gift_special = zen_get_products_special_price(zen_get_prid($products_id), true);
                 $gift_pba = zen_get_products_price_is_priced_by_attributes(zen_get_prid($products_id));
                 //echo '$products_id: ' . zen_get_prid($products_id) . ' price: ' . ($free_ship_check->fields['products_price'] + $this->attributes_price($products_id)) . ' vs special price: ' . $gift_special . ' qty: ' . $this->contents[$products_id]['qty'] . ' PBA: ' . ($gift_pba ? 'YES' : 'NO') . '<br>';
                 if (!$gift_pba && $gift_special != 0 && $gift_special != $free_ship_check->fields['products_price']) {
                     $gift_voucher += $gift_special * $this->contents[$products_id]['qty'];
                 } else {
                     $gift_voucher += ($free_ship_check->fields['products_price'] + $this->attributes_price($products_id)) * $this->contents[$products_id]['qty'];
                 }
             }
             // product_is_always_free_shipping = 2 is special requires shipping
             // Example: Product with download
             if (isset($this->contents[$products_id]['attributes']) and $free_ship_check->fields['product_is_always_free_shipping'] != 2) {
                 reset($this->contents[$products_id]['attributes']);
                 while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
                     $virtual_check_query = "select count(*) as total\n                                      from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n                                      where pa.products_id = '" . (int) $products_id . "'\n                                      and pa.options_values_id = '" . (int) $value . "'\n                                      and pa.products_attributes_id = pad.products_attributes_id";
                     $virtual_check = $db->Execute($virtual_check_query);
                     if ($virtual_check->fields['total'] > 0) {
                         switch ($this->content_type) {
                             case 'physical':
                                 $this->content_type = 'mixed';
                                 if ($gv_only == 'true') {
                                     return $gift_voucher;
                                 } else {
                                     return $this->content_type;
                                 }
                                 break;
                             default:
                                 $this->content_type = 'virtual';
                                 break;
                         }
                     } else {
                         switch ($this->content_type) {
                             case 'virtual':
                                 if ($free_ship_check->fields['products_virtual'] == '1') {
                                     $this->content_type = 'virtual';
                                 } else {
                                     $this->content_type = 'mixed';
                                     if ($gv_only == 'true') {
                                         return $gift_voucher;
                                     } else {
                                         return $this->content_type;
                                     }
                                 }
                                 break;
                             case 'physical':
                                 if ($free_ship_check->fields['products_virtual'] == '1') {
                                     $this->content_type = 'mixed';
                                     if ($gv_only == 'true') {
                                         return $gift_voucher;
                                     } else {
                                         return $this->content_type;
                                     }
                                 } else {
                                     $this->content_type = 'physical';
                                 }
                                 break;
                             default:
                                 if ($free_ship_check->fields['products_virtual'] == '1') {
                                     $this->content_type = 'virtual';
                                 } else {
                                     $this->content_type = 'physical';
                                 }
                         }
                     }
                 }
             } else {
                 switch ($this->content_type) {
                     case 'virtual':
                         if ($free_ship_check->fields['products_virtual'] == '1') {
                             $this->content_type = 'virtual';
                         } else {
                             $this->content_type = 'mixed';
                             if ($gv_only == 'true') {
                                 return $gift_voucher;
                             } else {
                                 return $this->content_type;
                             }
                         }
                         break;
                     case 'physical':
                         if ($free_ship_check->fields['products_virtual'] == '1') {
                             $this->content_type = 'mixed';
                             if ($gv_only == 'true') {
                                 return $gift_voucher;
                             } else {
                                 return $this->content_type;
                             }
                         } else {
                             $this->content_type = 'physical';
                         }
                         break;
                     default:
                         if ($free_ship_check->fields['products_virtual'] == '1') {
                             $this->content_type = 'virtual';
                         } else {
                             $this->content_type = 'physical';
                         }
                 }
             }
         }
     } else {
         $this->content_type = 'physical';
     }
     if ($gv_only == 'true') {
         return $gift_voucher;
     } else {
         return $this->content_type;
     }
 }
Example #8
0
function zen_get_products_discount_price_qty($product_id, $check_qty, $check_amount = 0)
{
    global $db, $cart;
    $new_qty = $_SESSION['cart']->in_cart_mixed_discount_quantity($product_id);
    // check for discount qty mix
    if ($new_qty > $check_qty) {
        $check_qty = $new_qty;
    }
    $product_id = (int) $product_id;
    $products_query = $db->Execute("select products_discount_type, products_discount_type_from, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id='" . $product_id . "'");
    $products_discounts_query = $db->Execute("select * from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $product_id . "' and discount_qty <='" . $check_qty . "' order by discount_qty desc");
    $display_price = zen_get_products_base_price($product_id);
    $display_specials_price = zen_get_products_special_price($product_id, true);
    switch ($products_query->fields['products_discount_type']) {
        // none
        case $products_discounts_query->EOF:
            //no discount applies
            $discounted_price = zen_get_products_actual_price($product_id);
            break;
        case '0':
            $discounted_price = zen_get_products_actual_price($product_id);
            break;
            // percentage discount
        // percentage discount
        case '1':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                // priced by attributes
                if ($check_amount != 0) {
                    $discounted_price = $check_amount - $check_amount * ($products_discounts_query->fields['discount_price'] / 100);
                    //echo 'ID#' . $product_id . ' Amount is: ' . $check_amount . ' discount: ' . $discounted_price . '<br />';
                    //echo 'I SEE 2 for ' . $products_query->fields['products_discount_type'] . ' - ' . $products_query->fields['products_discount_type_from'] . ' - '. $check_amount . ' new: ' . $discounted_price . ' qty: ' . $check_qty;
                } else {
                    $discounted_price = $display_price - $display_price * ($products_discounts_query->fields['discount_price'] / 100);
                }
            } else {
                if (!$display_specials_price) {
                    // priced by attributes
                    if ($check_amount != 0) {
                        $discounted_price = $check_amount - $check_amount * ($products_discounts_query->fields['discount_price'] / 100);
                    } else {
                        $discounted_price = $display_price - $display_price * ($products_discounts_query->fields['discount_price'] / 100);
                    }
                } else {
                    $discounted_price = $display_specials_price - $display_specials_price * ($products_discounts_query->fields['discount_price'] / 100);
                }
            }
            break;
            // actual price
        // actual price
        case '2':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                $discounted_price = $products_discounts_query->fields['discount_price'];
            } else {
                $discounted_price = $products_discounts_query->fields['discount_price'];
            }
            break;
            // amount offprice
        // amount offprice
        case '3':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                $discounted_price = $display_price - $products_discounts_query->fields['discount_price'];
            } else {
                if (!$display_specials_price) {
                    $discounted_price = $display_price - $products_discounts_query->fields['discount_price'];
                } else {
                    $discounted_price = $display_specials_price - $products_discounts_query->fields['discount_price'];
                }
            }
            break;
    }
    return $discounted_price;
}
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td colspan="2" class="breadCrumb"><?php 
echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR);
?>
</td>
  </tr>

<tr>
<td colspan="2" class="smallText">
<?php 
if (false) {
    echo 'Looking at ' . (int) $_GET['products_id'] . '<br />';
    echo 'Base Price ' . zen_get_products_base_price((int) $_GET['products_id']) . '<br />';
    echo 'Actual Price ' . zen_get_products_actual_price((int) $_GET['products_id']) . '<br />';
    echo 'Special Price ' . zen_get_products_special_price((int) $_GET['products_id'], true) . '<br />';
    echo 'Sale Maker Discount Type ' . zen_get_products_sale_discount_type((int) $_GET['products_id']) . '<br />';
    echo 'Discount Calc ' . zen_get_discount_calc((int) $_GET['products_id']) . '<br />';
    echo 'Discount Calc Attr $100 $75 $50 $25 ' . zen_get_discount_calc((int) $_GET['products_id'], true, 100) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 75) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 50) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 25) . '<br />';
}
?>
</td>
</tr>

<?php 
if (PRODUCT_INFO_PREVIOUS_NEXT == '1' or PRODUCT_INFO_PREVIOUS_NEXT == '3') {
    ?>
  <tr>
    <td colspan="2" align="center">
      <?php 
    require $template->get_template_dir('/tpl_products_next_previous.php', DIR_WS_TEMPLATE, $current_page_base, 'templates') . '/tpl_products_next_previous.php';
Example #10
0
function zen_get_products_discount_price_qty($product_id, $check_qty, $check_amount = 0)
{
    global $db, $cart;
    $new_qty = $_SESSION['cart']->in_cart_mixed_discount_quantity($product_id);
    // check for discount qty mix
    if ($new_qty > $check_qty) {
        $check_qty = $new_qty;
    }
    $product_id = (int) $product_id;
    $products_query = $db->Execute("select products_discount_type, products_discount_type_from, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id='" . (int) $product_id . "'");
    $products_query_discount_type = $products_query->fields['products_discount_type'];
    $products_discounts_query = $db->Execute("select * from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . (int) $product_id . "' and discount_qty <='" . (double) $check_qty . "' order by discount_qty desc");
    if ($products_discounts_query->RecordCount() <= 0 and $products_query_discount_type == 0) {
        $products_query2 = $db->Execute("select categories_discount_type, categories_discount_type_from FROM " . TABLE_CATEGORIES . " c , " . TABLE_PRODUCTS_TO_CATEGORIES . " pc where c.categories_id = pc.categories_id AND products_id='" . (int) $product_id . "'");
        $products_query_discount_type = $products_query2->fields['categories_discount_type'];
        $products_discounts_query = $db->Execute("SELECT * FROM " . TABLE_CATEGORIES_DISCOUNT_QUANTITY . " cd," . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE cd.categories_id = pc.categories_id AND products_id = " . (int) $product_id . " AND discount_qty <= '" . (double) $check_qty . "' ORDER BY discount_qty DESC");
    }
    if (zen_get_products_base_price($product_id) == 0) {
        $display_price = zen_get_products_sample_price($product_id);
    } else {
        $display_price = zen_get_products_base_price($product_id);
    }
    $display_specials_price = zen_get_products_special_price($product_id, true);
    switch ($products_query_discount_type) {
        // none
        case $products_discounts_query->EOF:
            //no discount applies
            $discounted_price = zen_get_products_actual_price($product_id);
            break;
        case '0':
            $discounted_price = zen_get_products_actual_price($product_id);
            break;
            // percentage discount
        // percentage discount
        case '1':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                // priced by attributes
                if ($check_amount != 0) {
                    $discounted_price = $check_amount - $check_amount * ($products_discounts_query->fields['discount_price'] / 100);
                    //echo 'ID#' . $product_id . ' Amount is: ' . $check_amount . ' discount: ' . $discounted_price . '<br />';
                    //echo 'I SEE 2 for ' . $products_query->fields['products_discount_type'] . ' - ' . $products_query->fields['products_discount_type_from'] . ' - '. $check_amount . ' new: ' . $discounted_price . ' qty: ' . $check_qty;
                } else {
                    $discounted_price = $display_price - $display_price * ($products_discounts_query->fields['discount_price'] / 100);
                }
            } else {
                if (!$display_specials_price) {
                    // priced by attributes
                    if ($check_amount != 0) {
                        $discounted_price = $check_amount - $check_amount * ($products_discounts_query->fields['discount_price'] / 100);
                    } else {
                        $discounted_price = $display_price - $display_price * ($products_discounts_query->fields['discount_price'] / 100);
                    }
                } else {
                    $discounted_price = $display_specials_price - $display_specials_price * ($products_discounts_query->fields['discount_price'] / 100);
                }
            }
            break;
            // actual price
        // actual price
        case '2':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                $discounted_price = $products_discounts_query->fields['discount_price'];
            } else {
                $discounted_price = $products_discounts_query->fields['discount_price'];
            }
            break;
            // amount offprice
        // amount offprice
        case '3':
            if ($products_query->fields['products_discount_type_from'] == '0') {
                $discounted_price = $display_price - $products_discounts_query->fields['discount_price'];
            } else {
                if (!$display_specials_price) {
                    $discounted_price = $display_price - $products_discounts_query->fields['discount_price'];
                } else {
                    $discounted_price = $display_specials_price - $products_discounts_query->fields['discount_price'];
                }
            }
            break;
    }
    return $discounted_price;
}
Example #11
0
 /**
  * Method to return details of all products in the cart
  *
  * @param boolean whether to check if cart contents are valid
  * @return array
  */
 function get_products($check_for_valid_cart = false)
 {
     global $db;
     $this->notify('NOTIFIER_CART_GET_PRODUCTS_START');
     if (!is_array($this->contents)) {
         return false;
     }
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $products_query = "select p.products_id, p.master_categories_id, p.products_status, pd.products_name, p.products_model, p.products_image,\n                                  p.products_price,p.products_price_sample, p.products_weight, p.products_tax_class_id,\n                                  p.products_quantity_order_min, p.products_quantity_order_units,\n                                  p.product_is_free, p.products_priced_by_attribute,\n                                  p.products_discount_type, p.products_discount_type_from\n                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd\n                           where p.products_id = '" . (int) $products_id . "'\n                           and pd.products_id = p.products_id\n                           and pd.language_id = '" . (int) $_SESSION['languages_id'] . "'";
         if ($products = $db->Execute($products_query)) {
             $prid = $products->fields['products_id'];
             $products_price = $products->fields['products_price'] == 0 ? $products->fields['products_price_sample'] : $products->fields['products_price'];
             //fix here
             /*
             $special_price = zen_get_products_special_price($prid);
             if ($special_price) {
             $products_price = $special_price;
             }
             */
             $special_price = zen_get_products_special_price($prid);
             if ($special_price and $products->fields['products_priced_by_attribute'] == 0) {
                 $products_price = $special_price;
             } else {
                 $special_price = 0;
             }
             if (zen_get_products_price_is_free($products->fields['products_id'])) {
                 // no charge
                 $products_price = 0;
             }
             // adjust price for discounts when priced by attribute
             if ($products->fields['products_priced_by_attribute'] == '1' and zen_has_product_attributes($products->fields['products_id'], 'false')) {
                 // reset for priced by attributes
                 //            $products_price = $products->fields['products_price'];
                 if ($special_price) {
                     $products_price = $special_price;
                 } else {
                     $products_price = $products->fields['products_price'];
                 }
             } else {
                 // discount qty pricing
                 $categories_query = $db->Execute("SELECT categories_discount_type FROM " . TABLE_CATEGORIES . " WHERE categories_id = " . zen_get_products_category_id($products_id));
                 if ($products->fields['products_discount_type'] != 0 || $categories_query->fields['categories_discount_type'] != 0) {
                     $products_price = zen_get_products_discount_price_qty($products->fields['products_id'], $this->contents[$products_id]['qty']);
                 }
             }
             // validate cart contents for checkout
             if ($check_for_valid_cart == true) {
                 $fix_once = 0;
                 // Check products_status if not already
                 $check_status = $products->fields['products_status'];
                 if ($check_status == 0) {
                     $fix_once++;
                     $_SESSION['valid_to_checkout'] = false;
                     $_SESSION['cart_errors'] .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_STATUS_SHOPPING_CART . '<br />';
                     $this->remove($products_id);
                 }
                 // check only if valid products_status
                 if ($fix_once == 0) {
                     $check_quantity = $this->contents[$products_id]['qty'];
                     $check_quantity_min = $products->fields['products_quantity_order_min'];
                     // Check quantity min
                     if ($new_check_quantity = $this->in_cart_mixed($prid)) {
                         $check_quantity = $new_check_quantity;
                     }
                 }
                 if ($fix_once == 0) {
                     if ($check_quantity < $check_quantity_min) {
                         $fix_once++;
                         $_SESSION['valid_to_checkout'] = false;
                         $_SESSION['cart_errors'] .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_MIN_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int) $prid, false, true) . '</span> ' . '<br />';
                     }
                 }
                 // Check Quantity Units if not already an error on Quantity Minimum
                 if ($fix_once == 0) {
                     $check_units = $products->fields['products_quantity_order_units'];
                     if (fmod_round($check_quantity, $check_units) != 0) {
                         $_SESSION['valid_to_checkout'] = false;
                         $_SESSION['cart_errors'] .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int) $prid, false, true) . '</span> ' . '<br />';
                     }
                 }
                 // Verify Valid Attributes
             }
             //clr 030714 update $products_array to include attribute value_text. This is needed for text attributes.
             // convert quantity to proper decimals
             if (QUANTITY_DECIMALS != 0) {
                 //          $new_qty = round($new_qty, QUANTITY_DECIMALS);
                 $fix_qty = $this->contents[$products_id]['qty'];
                 switch (true) {
                     case !strstr($fix_qty, '.'):
                         $new_qty = $fix_qty;
                         break;
                     default:
                         $new_qty = preg_replace('/[0]+$/', '', $this->contents[$products_id]['qty']);
                         break;
                 }
             } else {
                 $new_qty = $this->contents[$products_id]['qty'];
             }
             $check_unit_decimals = zen_get_products_quantity_order_units((int) $products->fields['products_id']);
             if (strstr($check_unit_decimals, '.')) {
                 $new_qty = round($new_qty, QUANTITY_DECIMALS);
             } else {
                 $new_qty = round($new_qty, 0);
             }
             if ($new_qty == (int) $new_qty) {
                 $new_qty = (int) $new_qty;
             }
             $products_array[] = array('id' => $products_id, 'category' => $products->fields['master_categories_id'], 'name' => $products->fields['products_name'], 'model' => $products->fields['products_model'], 'image' => $products->fields['products_image'], 'price' => $products->fields['product_is_free'] == '1' ? 0 : $products_price, 'quantity' => $new_qty, 'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id), 'final_price' => $products_price + $this->attributes_price($products_id), 'onetime_charges' => $this->attributes_price_onetime_charges($products_id, $new_qty), 'tax_class_id' => $products->fields['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '', 'attributes_values' => isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : '', 'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'], 'product_is_free' => $products->fields['product_is_free'], 'products_discount_type' => $products->fields['products_discount_type'], 'products_discount_type_from' => $products->fields['products_discount_type_from']);
         }
     }
     $this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
     return $products_array;
 }
    echo TEXT_PRODUCTS_DISCOUNT_QTY_TITLE;
    ?>
</td>
              <td class="main" align="left"><?php 
    echo TEXT_PRODUCTS_DISCOUNT_QTY;
    ?>
</td>
              <td class="main" align="left" style="border-right:0;"><?php 
    echo TEXT_PRODUCTS_DISCOUNT_PRICE;
    ?>
</td>
            </tr>
  <?php 
    $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($category_id);
    $display_price = zen_get_products_base_price($category_id);
    $display_specials_price = zen_get_products_special_price($category_id, true);
    $discount_query = "SELECT discount_id,discount_qty,discount_price FROM " . TABLE_CATEGORIES_DISCOUNT_QUANTITY . " WHERE categories_id = " . $category_id;
    $discount = $db->Execute($discount_query);
    $i = 0;
    while (!$discount->EOF) {
        $i++;
        $discount_name[] = array('id' => $i, 'discount_qty' => $discount->fields['discount_qty'], 'discount_price' => $discount->fields['discount_price']);
        $discount->MoveNext();
    }
    for ($i = 0, $n = 6; $i < $n; $i++) {
        switch ($pInfo->products_discount_type) {
            // none
            case '0':
                $discounted_price = 0;
                break;
                // percentage discount
Example #13
0
 /**
  * @author chenliujin <*****@*****.**>
  * @since 2016-09-29
  * TODO clear $db, $currencies
  */
 public static function GetPriceList($products_id)
 {
     global $db, $currencies;
     $price = new \stdClass();
     $product_check = $db->Execute("\n\t\t\tselect \n\t\t\t\tproducts_tax_class_id, \n\t\t\t\tproducts_price, \n\t\t\t\tproducts_priced_by_attribute, \n\t\t\t\tproduct_is_free, \n\t\t\t\tproduct_is_call, \n\t\t\t\tproducts_type \n\t\t\tfrom " . TABLE_PRODUCTS . " \n\t\t\twhere products_id = '" . (int) $products_id . "'" . " limit 1");
     // no prices on Document General
     if ($product_check->fields['products_type'] == 3) {
         return '';
     }
     $price->normal_price = zen_get_products_base_price($products_id);
     $price->special_price = zen_get_products_special_price($products_id, true);
     $price->sale_price = zen_get_products_special_price($products_id, false);
     if ($price->sale_price) {
         $price->sale_discount = $currencies->format($price->normal_price - $price->sale_price);
         $price->sale_discount .= '&nbsp;';
         $price->sale_discount .= '(' . number_format(100 - $price->sale_price / $price->normal_price * 100, SHOW_SALE_DISCOUNT_DECIMALS) . '%)';
     } else {
         $price->sale_discount = $currencies->format($price->normal_price - $price->special_price);
         $price->sale_discount .= '&nbsp;';
         $price->sale_discount .= '(' . number_format(100 - $price->special_price / $price->normal_price * 100, SHOW_SALE_DISCOUNT_DECIMALS) . '%)';
     }
     return $price;
 }
function eo_get_product_attribute_prices($attr_id, $attr_value = '', $qty = 1)
{
    global $db;
    $retval = array('onetime_charges' => 0, 'price' => 0);
    $attribute_price = $db->Execute('SELECT * ' . 'FROM `' . TABLE_PRODUCTS_ATTRIBUTES . '` ' . 'WHERE `products_attributes_id`=\'' . (int) $attr_id . '\'');
    $attr_id = (int) $attr_id;
    $qty = (int) $qty;
    $product_id = (int) $attribute_price->fields['products_id'];
    // Only check when attributes is not free or the product is not free
    if ($attribute_price->fields['product_attribute_is_free'] != '1' || !zen_get_products_price_is_free($product_id)) {
        // Handle based upon discount enabled
        if ($attribute_price->fields['attributes_discounted'] == '1') {
            // Calculate proper discount for attributes
            $added_charge = zen_get_discount_calc($product_id, $attr_id, $attribute_price->fields['options_values_price'], $qty);
        } else {
            $added_charge = $attribute_price->fields['options_values_price'];
        }
        // Handle negative price prefix
        // Other price prefixes ("+" and "") should add so no special processing
        if ($attribute_price->fields['price_prefix'] == '-') {
            $added_charge = -1 * $added_charge;
        }
        $retval['price'] += $added_charge;
        //////////////////////////////////////////////////
        // calculate additional charges
        // products_options_value_text
        if (zen_get_attributes_type($attr_id) == PRODUCTS_OPTIONS_TYPE_TEXT) {
            $text_words = zen_get_word_count_price($attr_value, $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']);
            $text_letters = zen_get_letters_count_price($attr_value, $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']);
            $retval['price'] += $text_letters;
            $retval['price'] += $text_words;
        }
        // attributes_price_factor
        $added_charge = 0;
        if ($attribute_price->fields['attributes_price_factor'] > 0) {
            $chk_price = zen_get_products_base_price($products_id);
            $chk_special = zen_get_products_special_price($products_id, false);
            $added_charge = zen_get_attributes_price_factor($chk_price, $chk_special, $attribute_price->fields['attributes_price_factor'], $attribute_price->fields['attributes_price_factor_offset']);
            $retval['price'] += $added_charge;
        }
        // attributes_qty_prices
        $added_charge = 0;
        if ($attribute_price->fields['attributes_qty_prices'] != '') {
            $chk_price = zen_get_products_base_price($products_id);
            $chk_special = zen_get_products_special_price($products_id, false);
            $added_charge = zen_get_attributes_qty_prices_onetime($attribute_price->fields['attributes_qty_prices'], $qty);
            $retval['price'] += $added_charge;
        }
        // attributes_price_onetime
        if ($attribute_price->fields['attributes_price_onetime'] > 0) {
            $retval['onetime_charges'] = (double) $attribute_price->fields['attributes_price_onetime'];
        }
        // attributes_price_factor_onetime
        $added_charge = 0;
        if ($attribute_price->fields['attributes_price_factor_onetime'] > 0) {
            $chk_price = zen_get_products_base_price($products_id);
            $chk_special = zen_get_products_special_price($products_id, false);
            $added_charge = zen_get_attributes_price_factor($chk_price, $chk_special, $attribute_price->fields['attributes_price_factor_onetime'], $attribute_price->fields['attributes_price_factor_onetime_offset']);
            $retval['onetime_charges'] += $added_charge;
        }
        // attributes_qty_prices_onetime
        $added_charge = 0;
        if ($attribute_price->fields['attributes_qty_prices_onetime'] != '') {
            $chk_price = zen_get_products_base_price($products_id);
            $chk_special = zen_get_products_special_price($products_id, false);
            $added_charge = zen_get_attributes_qty_prices_onetime($attribute_price->fields['attributes_qty_prices_onetime'], $qty);
            $retval['onetime_charges'] += $added_charge;
        }
        ////////////////////////////////////////////////
    }
    return $retval;
}
 					$option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price);
 					$option_names[$option_id] = $opt_products_options_name;
 					$option_values_names[$option_value_id] = $opt_products_options_values_name;
 				}
 			} */
 // Get Product Info
 $InfoQuery = "select p.products_model,p.products_price,pd.products_name,p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id=p.products_id where p.products_id='{$add_product_products_id}'";
 $result = $db->Execute($InfoQuery);
 #$row = zen_db_fetch_array($result);
 extract($result->fields, EXTR_PREFIX_ALL, "p");
 // Following functions are defined at the bottom of this file
 $CountryID = zen_get_country_id($order->delivery["country"]);
 $ZoneID = zen_get_zone_id($CountryID, $order->delivery["state"]);
 $ProductsTax = zen_get_tax_rate($p_products_tax_class_id, $CountryID, $ZoneID);
 if ($_POST[applyspecialstoprice] && zen_get_products_special_price((int) $add_product_products_id)) {
     $product_price_woa = zen_get_products_special_price((int) $add_product_products_id);
 } else {
     $product_price_woa = $p_products_price;
 }
 $Query = "insert into " . TABLE_ORDERS_PRODUCTS . " set\n\t\t\t\torders_id = {$oID},\n\t\t\t\tproducts_id = {$add_product_products_id},\n\t\t\t\tproducts_model = '{$p_products_model}',\n\t\t\t\tproducts_name = '" . str_replace("'", "&#39;", $p_products_name) . "',\n\t\t\t\tproducts_price = '{$product_price_woa}',\n\t\t\t\tfinal_price = '" . ($product_price_woa + $AddedOptionsPrice) . "',\n\t\t\t\tproducts_tax = '{$ProductsTax}',\n\t\t\t\tproducts_quantity = {$add_product_quantity},\n                                onetime_charges = {$AddedOptionsPrice_OneTime};";
 $db->Execute($Query);
 $new_product_id = zen_db_insert_id();
 //UPDATE_INVENTORY_QUANTITY_START##############################################################################################################
 if (STOCK_LIMITED == "true") {
     $db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $add_product_quantity . ", products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'");
 } else {
     $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'");
 }
 //UPDATE_INVENTORY_QUANTITY_END##############################################################################################################
 if ($_POST[optionstoadd] != NULL) {
     for ($i = 1; $i <= $_POST[optionstoadd]; $i++) {
}
switch (true) {
    case $products_discounts_query->fields['discount_qty'] <= 2:
        $show_qty = '1';
        break;
    case $products_quantity_order_min == $products_discounts_query->fields['discount_qty'] - 1 || $products_quantity_order_min == $products_discounts_query->fields['discount_qty']:
        $show_qty = $products_quantity_order_min;
        break;
    default:
        $show_qty = $products_quantity_order_min . '-' . number_format($products_discounts_query->fields['discount_qty'] - 1);
        break;
}
// $discounted_price = $products_discounts_query->fields['discount_price'];
// $currencies->display_price($discounted_price, zen_get_tax_rate(1), 1)
$display_price = zen_get_products_base_price($products_id_current);
$display_specials_price = zen_get_products_special_price($products_id_current, true);
$disc_cnt = 1;
$quantityDiscounts = array();
$columnCount = 0;
while (!$products_discounts_query->EOF) {
    $disc_cnt++;
    switch ($products_discount_type) {
        // none
        case '0':
            $quantityDiscounts[$columnCount]['discounted_price'] = 0;
            break;
            // percentage discount
        // percentage discount
        case '1':
            if ($products_discount_type_from == '0') {
                $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - $display_price * ($products_discounts_query->fields['discount_price'] / 100);
Example #17
0
        if ((!isset($_GET['sID']) || isset($_GET['sID']) && $_GET['sID'] == $specials->fields['specials_id']) && !isset($sInfo)) {
            $products = $db->Execute("select products_image\n                                  from " . TABLE_PRODUCTS . "\n                                  where products_id = '" . (int) $specials->fields['products_id'] . "'");
            $sInfo_array = array_merge($specials->fields, $products->fields);
            $sInfo = new objectInfo($sInfo_array);
        }
        if (isset($sInfo) && is_object($sInfo) && $specials->fields['specials_id'] == $sInfo->specials_id) {
            echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
        } else {
            echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials->fields['specials_id'] . '&action=edit') . '\'">' . "\n";
        }
        if ($specials->fields['products_priced_by_attribute'] == '1') {
            $specials_current_price = zen_get_products_base_price($specials->fields['products_id']);
        } else {
            $specials_current_price = $specials->fields['products_price'];
        }
        $sale_price = zen_get_products_special_price($specials->fields['products_id'], false);
        ?>
                <td  class="dataTableContent" align="right"><?php 
        echo $specials->fields['products_id'];
        ?>
&nbsp;</td>
                <td  class="dataTableContent"><?php 
        echo $specials->fields['products_name'];
        ?>
</td>
                <td  class="dataTableContent" align="left"><?php 
        echo $specials->fields['products_model'];
        ?>
&nbsp;</td>
                <td colspan="2" class="dataTableContent" align="right"><?php 
        echo zen_get_products_display_price($specials->fields['products_id']);
<?php

/**
 * whats_new sidebox - displays a random "new" product
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: whats_new.php 2769 2006-01-02 07:34:58Z drbyte $
 */
// display limits
$display_limit = zen_get_products_new_timelimit();
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price\r\n                           from " . TABLE_PRODUCTS . " p\r\n                           where p.products_status = 1 " . $display_limit . "\r\n                           limit " . MAX_RANDOM_SELECT_NEW;
$random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);
if ($random_whats_new_sidebox_product->RecordCount() > 0) {
    $whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['products_name'] = zen_get_products_name($random_whats_new_sidebox_product->fields['products_id']);
    $random_whats_new_sidebox_product->fields['specials_new_products_price'] = zen_get_products_special_price($random_whats_new_sidebox_product->fields['products_id']);
    require $template->get_template_dir('tpl_whats_new.php', DIR_WS_TEMPLATE, $current_page_base, 'sideboxes') . '/tpl_whats_new.php';
    $title = BOX_HEADING_WHATS_NEW;
    $title_link = FILENAME_PRODUCTS_NEW;
    require $template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base, 'common') . '/' . $column_box_default;
}
    while (!$all_wholesale_db->EOF) {
        $tmp_w_pid = $all_wholesale_db->fields['products_id'];
        $tmp_qty_order_min = $all_wholesale_db->fields['products_quantity_order_min'];
        $tmp_dis_type = $all_wholesale_db->fields['products_discount_type'];
        $tmp_dis_type_from = $all_wholesale_db->fields['products_discount_type_from'];
        $price_data = array();
        $dis_qty_sql = 'select discount_qty,discount_price 
					 from ' . TABLE_PRODUCTS_DISCOUNT_QUANTITY . '
					 where products_id=' . $tmp_w_pid . ' 
					 and   discount_qty!=0 
					 order by discount_qty';
        $dis_qty_db = $db->Execute($dis_qty_sql);
        if ($dis_qty_db->RecordCount() > 0) {
            $dis_cnt = 0;
            $display_price = zen_get_products_base_price($tmp_w_pid);
            $display_specials_price = zen_get_products_special_price($tmp_w_pid, true);
            //################Begin:set first price value##################
            if ($display_specials_price == false) {
                $show_price = $display_price;
            } else {
                $show_price = $display_specials_price;
            }
            switch (true) {
                case $dis_qty_db->fields['discount_qty'] <= 2:
                    $show_qty = '1';
                    break;
                case $tmp_qty_order_min == $dis_qty_db->fields['discount_qty'] - 1 || $tmp_qty_order_min == $dis_qty_db->fields['discount_qty']:
                    $show_qty = $tmp_qty_order_min;
                    break;
                default:
                    $show_qty = $tmp_qty_order_min . '-' . number_format($dis_qty_db->fields['discount_qty'] - 1);
	       <td class="main" align="center"><?php 
                echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED_W;
                ?>
</td>
// Dual Pricing end
<?php 
            }
            ?>
          </tr>
<?php 
            $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
            $display_price = zen_get_products_base_price($_GET['products_filter']);
            // Dual Pricing start
            $display_price_w = zen_get_products_base_price_w($_GET['products_filter']);
            // Dual Pricing end
            $display_specials_price = zen_get_products_special_price($_GET['products_filter'], false);
            //  $display_sale_price = zen_get_products_special_price($_GET['products_filter'], false);
            for ($i = 0, $n = sizeof($discount_name); $i < $n; $i++) {
                switch ($pInfo->products_discount_type) {
                    // none
                    case '0':
                        $discounted_price = 0;
                        break;
                        // percentage discount
                    // percentage discount
                    case '1':
                        if ($pInfo->products_discount_type_from == '0') {
                            $discounted_price = $display_price - $display_price * ($discount_name[$i]['discount_price'] / 100);
                            // Dual Pricing start
                            $discounted_price_w = $display_price_w - $display_price_w * ($discount_name[$i]['discount_price_w'] / 100);
                        } else {
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_DOCUMENT_GENERAL_INFO');
$module_show_categories = DOCUMENT_GENERAL_INFO_CATEGORIES;
$sql = "select count(*) as total\n          from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd\n          where    p.products_status = '1'\n          and      p.products_id = '" . (int) $_GET['products_id'] . "'\n          and      pd.products_id = p.products_id\n          and      pd.language_id = '" . (int) $_SESSION['languages_id'] . "'";
$res = $db->Execute($sql);
if ($res->fields['total'] < 1) {
    $tpl_page_body = '/tpl_product_info_noproduct.php';
} else {
    $tpl_page_body = '/tpl_document_general_info_display.php';
    $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "\n            set        products_viewed = products_viewed+1\n            where      products_id = '" . (int) $_GET['products_id'] . "'\n            and        language_id = '" . (int) $_SESSION['languages_id'] . "'";
    $res = $db->Execute($sql);
    $sql = "select p.products_id, pd.products_name,\n                  pd.products_description, p.products_model,\n                  p.products_quantity, p.products_image,\n                  pd.products_url, p.products_price,\n                  p.products_tax_class_id, p.products_date_added,\n                  p.products_date_available, p.manufacturers_id, p.products_quantity,\n                  p.products_weight, p.products_priced_by_attribute, p.product_is_free,\n                  p.products_qty_box_status,\n                  p.products_quantity_order_max,\n                  p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter\n           from   " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd\n           where  p.products_status = '1'\n           and    p.products_id = '" . (int) $_GET['products_id'] . "'\n           and    pd.products_id = p.products_id\n           and    pd.language_id = '" . (int) $_SESSION['languages_id'] . "'";
    $product_info = $db->Execute($sql);
    $products_price_sorter = $product_info->fields['products_price_sorter'];
    $products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
    $manufacturers_name = zen_get_products_manufacturers_name((int) $_GET['products_id']);
    if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
        $specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
    }
    // set flag for attributes module usage:
    $flag_show_weight_attrib_for_this_prod_type = SHOW_DOCUMENT_GENERAL_INFO_WEIGHT_ATTRIBUTES;
    // get attributes
    require DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES);
    // if review must be approved or disabled do not show review
    $review_status = " and r.status = '1'";
    $reviews_query = "select count(*) as count from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd\n                       where r.products_id = '" . (int) $_GET['products_id'] . "'\n                       and r.reviews_id = rd.reviews_id\n                       and rd.languages_id = '" . (int) $_SESSION['languages_id'] . "'" . $review_status;
    $reviews = $db->Execute($reviews_query);
}
require DIR_WS_MODULES . zen_get_module_directory('product_prev_next.php');
$products_name = $product_info->fields['products_name'];
$products_model = $product_info->fields['products_model'];
$products_description = $product_info->fields['products_description'];
function get_special_price($products_id)
{
    global $db, $currencies;
    switch (true) {
        case CUSTOMERS_APPROVAL == '1' && $_SESSION['customer_id'] == '':
            // customer must be logged in to browse
            return '';
            break;
        case CUSTOMERS_APPROVAL == '2' && $_SESSION['customer_id'] == '':
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE;
            break;
        case CUSTOMERS_APPROVAL == '3' && TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != '':
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
            break;
        case CUSTOMERS_APPROVAL_AUTHORIZATION != '0' && CUSTOMERS_APPROVAL_AUTHORIZATION != '3' && $_SESSION['customer_id'] == '':
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
        case CUSTOMERS_APPROVAL_AUTHORIZATION != '0' && CUSTOMERS_APPROVAL_AUTHORIZATION != '3' && $_SESSION['customers_authorization'] > '0':
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
        default:
            // proceed normally
            break;
    }
    // show case only
    if (STORE_STATUS != '0') {
        if (STORE_STATUS == '1') {
            return '';
        }
    }
    $product_check = $db->Execute("select products_tax_class_id, products_price, products_priced_by_attribute, product_is_free, product_is_call, products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'" . " limit 1");
    // no prices on Document General
    if ($product_check->fields['products_type'] == 3) {
        return '';
    }
    $display_special_price = zen_get_products_special_price($products_id, true);
    $special_price = 0;
    if ($display_special_price) {
        $special_price = $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id']));
    }
    return $special_price;
}