/** * Test product base price. */ public function testBasePrice() { foreach ($this->get('productService')->getAllProducts(false, 1) as $product) { $offers = $product->getOffers(); // without tax $this->assertEquals(zen_get_products_base_price($product->getId()), $offers->getBasePrice(false), '%s productId=' . $product->getId()); } }
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; }
function zen_draw_products_pull_down_attributes($name, $parameters = '', $exclude = '') { global $db, $currencies; if ($exclude == '') { $exclude = array(); } $select_string = '<select name="' . $name . '"'; if ($parameters) { $select_string .= ' ' . $parameters; } $select_string .= '>'; $new_fields = ', p.products_model'; $products = $db->Execute("select distinct p.products_id, pd.products_name, p.products_price" . $new_fields . "\r\n from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_ATTRIBUTES . " pa " . "\r\n where p.products_id= pa.products_id and p.products_id = pd.products_id\r\n and pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\r\n order by products_name"); while (!$products->EOF) { if (!in_array($products->fields['products_id'], $exclude)) { $display_price = zen_get_products_base_price($products->fields['products_id']); $select_string .= '<option value="' . $products->fields['products_id'] . '">' . $products->fields['products_name'] . ' (' . TEXT_MODEL . ' ' . $products->fields['products_model'] . ') (' . $currencies->format($display_price) . ')</option>'; } $products->MoveNext(); } $select_string .= '</select>'; return $select_string; }
function zen_draw_products_pull_down_attributes($name, $parameters = '', $exclude = '') { global $gBitDb, $currencies; if ($exclude == '') { $exclude = array(); } $select_string = '<select class="form-control" name="' . $name . '"'; if ($parameters) { $select_string .= ' ' . $parameters; } $select_string .= '>'; $new_fields = ', p.`products_model`'; $products = $gBitDb->query("select distinct pom.`products_id`, pd.`products_name`, p.`products_price`" . $new_fields . "\n FROM " . TABLE_PRODUCTS . " p \n INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON(p.`products_id` = pd.`products_id`) \n\t\t\t\t\t\t\t\tINNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON(p.`products_id`= pom.`products_id`)\n INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON(pa.`products_options_values_id`=pom.`products_options_values_id`)\n WHERE pd.`language_id` = ?\n ORDER BY `products_name`", array((int) $_SESSION['languages_id'])); while (!$products->EOF) { if (!in_array($products->fields['products_id'], $exclude)) { $display_price = zen_get_products_base_price($products->fields['products_id']); $select_string .= '<option value="' . $products->fields['products_id'] . '">' . $products->fields['products_name'] . ' (' . TEXT_MODEL . ' ' . $products->fields['products_model'] . ') (' . $currencies->format($display_price) . ')</option>'; } $products->MoveNext(); } $select_string .= '</select>'; return $select_string; }
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; }
$contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '<br><b>' . $sInfo->products_name . '</b>'); $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; case 'pre_add': $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_PRE_ADD_SPECIALS . '</b>'); $contents = array('form' => zen_draw_form('specials', FILENAME_SPECIALS, 'action=pre_add_confirmation')); $contents[] = array('text' => TEXT_INFO_PRE_ADD_INTRO); $contents[] = array('text' => '<br />' . TEXT_PRE_ADD_PRODUCTS_ID . '<br>' . zen_draw_input_field('pre_add_products_id', '', zen_set_field_length(TABLE_SPECIALS, 'products_id'))); $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); break; default: if (is_object($sInfo)) { $heading[] = array('text' => '<b>' . $sInfo->products_name . '</b>'); if ($sInfo->products_priced_by_attribute == '1') { $specials_current_price = zen_get_products_base_price($sInfo->products_id); } else { $specials_current_price = $sInfo->products_price; } $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit&products_filter=' . $sInfo->products_id) . '">' . zen_image_button('button_products_price_manager.gif', IMAGE_PRODUCTS_PRICE_MANAGER) . '</a>'); $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . zen_date_short($sInfo->specials_date_added)); $contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . zen_date_short($sInfo->specials_last_modified)); $contents[] = array('align' => 'center', 'text' => '<br>' . zen_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)); $contents[] = array('text' => '<br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($specials_current_price)); $contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price)); $contents[] = array('text' => '' . TEXT_INFO_DISPLAY_PRICE . ' ' . zen_get_products_display_price($sInfo->products_id)); $contents[] = array('text' => '<br>' . TEXT_INFO_AVAILABLE_DATE . ' <b>' . (($specials->fields['specials_date_available'] != '0001-01-01' and $specials->fields['specials_date_available'] != '') ? zen_date_short($specials->fields['specials_date_available']) : TEXT_NONE) . '</b>'); $contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . (($specials->fields['expires_date'] != '0001-01-01' and $specials->fields['expires_date'] != '') ? zen_date_short($specials->fields['expires_date']) : TEXT_NONE) . '</b>'); $contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . zen_date_short($sInfo->date_status_change)); $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_CATEGORIES, '&action=new_product' . '&cPath=' . zen_get_product_path($sInfo->products_id, 'override') . '&pID=' . $sInfo->products_id . '&product_type=' . zen_get_products_type($sInfo->products_id)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '<br />' . TEXT_PRODUCT_EDIT . '</a>');
$lc_align = ''; $list_box_contents = array(); //echo $listing_split->sql_query; //print_r(explode(' ',zen_products_id_in_category($current_category_id))); if (zen_count_products_in_category($current_category_id) > 0) { $listing = $db->Execute($listing_split->sql_query); $row = 0; while (!$listing->EOF) { if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) { $list_box_contents[$row]['products_image'] = ''; } else { $list_box_contents[$row]['products_image'] = $listing->fields['products_image']; } $list_box_contents[$row]['products_name'] = $listing->fields['products_name']; $list_box_contents[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), 100); $list_box_contents[$row]['products_price'] = zen_get_products_base_price($listing->fields['products_id']); $list_box_contents[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($listing->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents[$row]['products_status'] = $listing->fields['products_status']; if ($listing->fields['product_is_always_free_shipping'] == 0) { $list_box_contents[$row]['product_is_always_free_shipping'] = ''; } else { $list_box_contents[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>'; } if ($listing->fields['product_is_free'] == 0) { $list_box_contents[$row]['product_is_free'] = ''; } else { $list_box_contents[$row]['product_is_free'] = '<span class="free"></span>'; } $list_box_contents[$row]['products_quantity_order_min'] = $listing->fields['products_quantity_order_min']; $list_box_contents[$row]['products_id'] = $listing->fields['products_id']; $list_box_contents[$row]['products_quantity'] = $listing->fields['products_quantity'];
/** * Method to calculate one time price of attributes for a given item * * @param mixed the product ID of the item to check * @param decimal item quantity * @return decimal the pice of the items attributes */ public function attributes_price_onetime_charges($products_id, $qty) { $attributes_price_onetime = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = "select *\n from %table.products_attributes%\n where products_id = '" . (int) $products_id . "'\n and options_id = '" . (int) $option . "'\n and options_values_id = '" . (int) $value . "'"; $attribute_price = $this->getDb()->Execute($attribute_price_query); $new_attributes_price = 0; $discount_type_id = ''; $sale_maker_discount = ''; if ($attribute_price->fields['product_attribute_is_free'] == '1' and zen_get_products_price_is_free((int) $products_id)) { // no charge } else { $discount_type_id = ''; $sale_maker_discount = ''; $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty); ////////////////////////////////////////////////// // calculate additional one time charges //// one time charges // attributes_price_onetime if ($attribute_price->fields['attributes_price_onetime'] > 0) { if ((int) $products_id != $products_id) { die('I DO NOT MATCH ' . $products_id); } $attributes_price_onetime += $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']); $attributes_price_onetime += $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); $attributes_price_onetime += $added_charge; } } } } return $attributes_price_onetime; }
$also_purchased_products = $db->Execute(sprintf(SQL_ALSO_PURCHASED, (int) $_GET['products_id'], (int) $_GET['products_id'])); $num_products_ordered = $also_purchased_products->RecordCount(); $row = 0; $col = 0; $list_box_contents = array(); $title = ''; // show only when 1 or more and equal to or greater than minimum set in admin if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED && $num_products_ordered > 0) { while (!$also_purchased_products->EOF) { //caizhouqing update by bof $rs = $db->Execute("select specials_new_products_price,products_id from specials where products_id=" . $also_purchased_products->fields['products_id']); $products_id = $rs->fields['products_id']; if ($products_id == $also_purchased_products->fields['products_id']) { $specials_price = $rs->fields['specials_new_products_price']; } else { $specials_price = zen_get_products_base_price($also_purchased_products->fields['products_id']); } //caizhouqing update by eof pro_show_right $also_purchased_products->fields['products_name'] = zen_get_products_name($also_purchased_products->fields['products_id']); $list_box_contents[$row][$col] = array('params' => 'class="top_selling"', 'text' => (($also_purchased_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<li><a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . zen_image_OLD(DIR_WS_IMAGES . $also_purchased_products->fields['products_image'], $also_purchased_products->fields['products_name'], '42', '42', ' class="fl"') . '</a>') . '<span><a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . substr($also_purchased_products->fields['products_name'], 0, 16) . '...' . '</a><br/><strong class="red">' . $currencies->display_price($specials_price, zen_get_tax_rate($products_tax_class_id)) . '</strong></span></li>'); $col++; if ($col > SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS - 1) { $col = 0; $row++; } $also_purchased_products->MoveNext(); } } if ($also_purchased_products->RecordCount() > 0 && $also_purchased_products->RecordCount() >= MIN_DISPLAY_ALSO_PURCHASED) { $title = '<h4 class="line_120 margin_t">' . TEXT_ALSO_PURCHASED_PRODUCTS . '</h4>'; $zc_show_also_purchased = true;
var FRIENDLY_URLS='true'; var symbolLeft='<?php echo $currencies->display_symbol_left($_SESSION['currency']); ?> '; var symbolRight=''; var min_quantity=<?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> ; var discount = new Array(); discount[0] ="<?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> -<?php echo number_format(zen_get_products_base_price($_GET['products_id']) == 0 ? zen_get_products_sample_price($_GET['products_id']) : zen_get_products_base_price($_GET['products_id']), 2); ?> -0-0"; function formatC(s, flag){ if(flag == null){ flag =true; } s = s + ''; if(/[^0-9\.]/.test(s)) return "invalid value"; s=s.replace(/^(\d*)$/,"$1."); s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1"); s=s.replace(".",","); var re=/(\d)(\d{3},)/; while(re.test(s)) s=s.replace(re,"$1,$2"); s=s.replace(/,(\d\d)$/,".$1"); if(flag){
echo zen_href_link(zen_get_info_page($flash_page_items[$i]['products_id']), 'products_id=' . $flash_page_items[$i]['products_id']); ?> "><?php echo zen_image_OLD(DIR_WS_IMAGES . $flash_page_items[$i]['products_image'], SEO_COMMON_KEYWORDS . ' ' . $flash_page_items[$i]['products_name'], 79, 79, 'id="cell_img' . $i . '" class="' . ($flash_page_items[$i]['products_id'] == $_GET['products_id'] ? 'imgborder' : '') . '"'); ?> </a><p><strong id="cell_price<?php echo $i; ?> " class="red"><?php if (!empty($flash_page_items[$i]['specials_price'])) { //caizhouqing by bof $products_price = $products_price * ($flash_page_items[$i]['specials_price'] / $products_price); echo $list_box_contents[$row]['products_price'] == 0 ? $currencies->display_price($products_price, zen_get_tax_rate($products_tax_class_id)) : $currencies->display_price($products_price, zen_get_tax_rate($products_tax_class_id)); } else { //caizhouqing by eof echo $currencies->display_price(zen_get_products_base_price($flash_page_items[$i]['products_id']) == 0 ? zen_get_products_sample_price($flash_page_items[$i]['products_id']) : zen_get_products_base_price($flash_page_items[$i]['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id'])); } ?> </strong></p> </li> <?php //print_r($flash_page_items[$i]); } ?> </ul> </div> <?php if (intval($flash_page->RecordCount()) > 1) { ?> <script type="text/javascript">
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; }
<td class="main" align="left"><?php 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;
//--></script> <script> var FRIENDLY_URLS='true'; var symbolLeft='<?php echo $currencies->display_symbol_left($_SESSION['currency']); ?> '; var symbolRight=''; var min_quantity = <?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> ; var discount = new Array(); <?php $jsPrice = $currencies->noSymbolDisplayPrice(zen_get_products_base_price($_GET['products_id']) == 0 ? zen_get_products_sample_price($_GET['products_id']) : zen_get_products_base_price($_GET['products_id']), zen_get_tax_rate($_GET['products_id'])); ?> discount[0] ="<?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> -<?php echo $jsPrice; ?> -<?php echo zen_get_product_is_always_free_shipping((int) $_GET['products_id']) ? 1 : 0; ?> -0"; function formatC(s, flag){ if(flag == null){ flag =true; }
/** * @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 .= ' '; $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 .= ' '; $price->sale_discount .= '(' . number_format(100 - $price->special_price / $price->normal_price * 100, SHOW_SALE_DISCOUNT_DECIMALS) . '%)'; } return $price; }
$free_shipping_query_raw2 = $db->bindVars($free_shipping_query_raw2, ':languageID', $_SESSION['languages_id'], 'integer'); $free_shipping_split2 = new splitPageResults($free_shipping_query_raw2, isset($_GET['pagesize']) ? $_GET['pagesize'] : 24); //check to see if we are in normal mode ... not showcase, not maintenance, etc $show_submit = zen_run_normal(); $free_shipping2 = $db->Execute($free_shipping_split2->sql_query); if ($free_shipping2->RecordCount() > 0) { $row = 0; while (!$free_shipping2->EOF) { if ($free_shipping2->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) { $list_box_contents2[$row]['products_image'] = ''; } else { $list_box_contents2[$row]['products_image'] = $free_shipping2->fields['products_image']; } $list_box_contents2[$row]['products_name'] = $free_shipping2->fields['products_name']; $list_box_contents2[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($free_shipping2->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); $list_box_contents2[$row]['products_price'] = zen_get_products_base_price($free_shipping2->fields['products_id']); $list_box_contents2[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($free_shipping2->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_status'] = $free_shipping2->fields['products_status']; if ($free_shipping2->fields['product_is_always_free_shipping'] == 0) { $list_box_contents2[$row]['product_is_always_free_shipping'] = ''; } else { $list_box_contents2[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>'; } $list_box_contents2[$row]['products_quantity_order_min'] = $free_shipping2->fields['products_quantity_order_min']; $list_box_contents2[$row]['products_id'] = $free_shipping2->fields['products_id']; $list_box_contents2[$row]['products_quantity'] = $free_shipping2->fields['products_quantity']; $list_box_contents2[$row]['products_price_retail'] = $currencies->display_price($free_shipping2->fields['products_price_retail'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_price_sample'] = $currencies->display_price($free_shipping2->fields['products_price_sample'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['product_is_wholesale'] = $free_shipping2->fields['product_is_wholesale']; $list_box_contents2[$row]['product_wholesale_min'] = $free_shipping2->fields['product_wholesale_min']; $free_shipping2->MoveNext();
$row++; } } $advanced_search_split2 = new splitPageResults($listing_sql2, isset($_GET['pagesize']) ? $_GET['pagesize'] : MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page'); $advanced_search2 = $db->Execute($advanced_search_split2->sql_query); if ($advanced_search2->RecordCount() > 0) { $row = 0; while (!$advanced_search2->EOF) { if ($advanced_search2->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) { $list_box_contents2[$row]['products_image'] = ''; } else { $list_box_contents2[$row]['products_image'] = $advanced_search2->fields['products_image']; } $list_box_contents2[$row]['products_name'] = $advanced_search2->fields['products_name']; $list_box_contents2[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($advanced_search2->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); $list_box_contents2[$row]['products_price'] = zen_get_products_base_price($advanced_search2->fields['products_id']); $list_box_contents2[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($advanced_search2->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_status'] = $advanced_search2->fields['products_status']; if ($advanced_search2->fields['product_is_always_free_shipping'] == 0) { $list_box_contents2[$row]['product_is_always_free_shipping'] = ''; } else { $list_box_contents2[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>'; } $list_box_contents2[$row]['products_quantity_order_min'] = $advanced_search2->fields['products_quantity_order_min']; $list_box_contents2[$row]['products_id'] = $advanced_search2->fields['products_id']; $list_box_contents2[$row]['products_quantity'] = $advanced_search2->fields['products_quantity']; $list_box_contents2[$row]['products_price_retail'] = $currencies->display_price($advanced_search2->fields['products_price_retail'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_price_sample'] = $currencies->display_price($advanced_search2->fields['products_price_sample'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['product_is_wholesale'] = $advanced_search2->fields['product_is_wholesale']; $list_box_contents2[$row]['product_wholesale_min'] = $advanced_search2->fields['product_wholesale_min']; $advanced_search2->MoveNext();
} } break; // actual price // actual price case '2': if ($pInfo->products_discount_type_from == '0') { $discounted_price = $discount['discount_price']; } else { $discounted_price = $discount['discount_price']; } break; // amount offprice // amount offprice case '3': $display_price = zen_get_products_base_price($_GET['products_id']); if ($pInfo->products_discount_type_from == '0') { $discounted_price = $display_price - $discount['discount_price']; } else { if (!$display_specials_price) { $discounted_price = $display_price - $discount['discount_price']; } else { $discounted_price = $display_specials_price - $discount['discount_price']; } } break; } ?> <tr> <td class="main"><?php echo tra(TEXT_PRODUCTS_DISCOUNT);
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 = ' ' . '<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 = ' ' . '<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 = ' ' . '<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; }
function all_products_array($first_option = false, $show_price = false, $show_model = false, $show_id = false) { global $db, $currencies; if (!isset($currencies)) { require DIR_WS_CLASSES . 'currencies.php'; $currencies = new currencies(); } $products_array = array(); if ($first_option) { $products_array[] = array('id' => '', 'text' => $first_option); } $products = $db->Execute("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " order by products_name asc"); while (!$products->EOF) { $display_price = zen_get_products_base_price($products->fields['products_id']); $products_array[] = array('id' => $products->fields['products_id'], 'text' => $products->fields['products_name'] . ($show_price ? ' (' . $currencies->format($display_price) . ')' : '') . ($show_model ? ' [' . $products->fields['products_model'] . ']' : '') . ($show_id ? ' [' . $products->fields['products_id'] . ']' : '')); $products->MoveNext(); } return $products_array; }
if (empty($action)) { ?> <td align="center"><?php echo '<a href="' . zen_href_link(FILENAME_FEATURED, (isset($_GET['page']) && $_GET['page'] > 0 ? 'page=' . $_GET['page'] . '&' : '') . 'action=new') . '">' . zen_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?> </td> <?php } if ($action == 'new' || $action == 'edit') { $form_action = 'insert'; if ($action == 'edit' && isset($_GET['fID'])) { $form_action = 'update'; $product = $db->Execute("select p.products_id, pd.products_name, p.products_price, p.products_priced_by_attribute,\n f.expires_date, f.featured_date_available\n from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_FEATURED . " f\n where p.products_id = pd.products_id\n and pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n and p.products_id = f.products_id\n and f.featured_id = '" . (int) $_GET['fID'] . "'"); $fInfo = new objectInfo($product->fields); if ($fInfo->products_priced_by_attribute == '1') { $fInfo->products_price = zen_get_products_base_price($product->fields['products_id']); } } else { $fInfo = new objectInfo(array()); // create an array of featured products, which will be excluded from the pull down menu of products // (when creating a new featured product) $featured_array = array(); $featured = $db->Execute("select p.products_id, p.products_model\n from " . TABLE_PRODUCTS . " p, " . TABLE_FEATURED . " f\n where f.products_id = p.products_id"); while (!$featured->EOF) { $featured_array[] = $featured->fields['products_id']; $featured->MoveNext(); } // do not include things that cannot go in the cart $not_for_cart = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type= pt.type_id where pt.allow_add_to_cart = 'N'"); while (!$not_for_cart->EOF) { $featured_array[] = $not_for_cart->fields['products_id'];
$products_new_query_raw2 = $db->bindVars($products_new_query_raw2, ':languageID', $_SESSION['languages_id'], 'integer'); $products_new_split2 = new splitPageResults($products_new_query_raw2, isset($_GET['pagesize']) ? $_GET['pagesize'] : 24); //check to see if we are in normal mode ... not showcase, not maintenance, etc $show_submit = zen_run_normal(); $products_new2 = $db->Execute($products_new_split2->sql_query); if ($products_new2->RecordCount() > 0) { $row = 0; while (!$products_new2->EOF) { if ($products_new2->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) { $list_box_contents2[$row]['products_image'] = ''; } else { $list_box_contents2[$row]['products_image'] = $products_new2->fields['products_image']; } $list_box_contents2[$row]['products_name'] = $products_new2->fields['products_name']; $list_box_contents2[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($products_new2->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); $list_box_contents2[$row]['products_price'] = zen_get_products_base_price($products_new2->fields['products_id']); $list_box_contents2[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($products_new2->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_status'] = $products_new2->fields['products_status']; if ($products_new2->fields['product_is_always_free_shipping'] == 0) { $list_box_contents2[$row]['product_is_always_free_shipping'] = ''; } else { $list_box_contents2[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>'; } $list_box_contents2[$row]['products_quantity_order_min'] = $products_new2->fields['products_quantity_order_min']; $list_box_contents2[$row]['products_id'] = $products_new2->fields['products_id']; $list_box_contents2[$row]['products_quantity'] = $products_new2->fields['products_quantity']; $list_box_contents2[$row]['products_price_retail'] = $currencies->display_price($products_new2->fields['products_price_retail'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['products_price_sample'] = $currencies->display_price($products_new2->fields['products_price_sample'], zen_get_tax_rate($product_check->fields['products_tax_class_id'])); $list_box_contents2[$row]['product_is_wholesale'] = $products_new2->fields['product_is_wholesale']; $list_box_contents2[$row]['product_wholesale_min'] = $products_new2->fields['product_wholesale_min']; $products_new2->MoveNext();
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: sp_products.php 2718 2010-04-07 23:59:42:39Z john $ */ // test if box should display if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } $show_same_price = true; //same price sp if (zen_not_null($_GET['products_id']) && $show_same_price == true && $current_page_base == 'product_info') { $sp_products = array(); $sp_pid = explode(":", $_GET['products_id']); $real_pid = $sp_pid[0]; $m_cate_db = $db->Execute("select p2.master_categories_id from products p2 where p2.products_id=" . $real_pid); $m_cate_id = $m_cate_db->fields['master_categories_id']; $sp_price = zen_get_products_base_price($real_pid); $sp_products_query = "select distinct p.products_id, pd.products_name,p.products_image,p.products_price \n\t\t\t\t\t\t\tfrom " . TABLE_PRODUCTS . " p, \n\t\t\t\t\t\t\t\t " . TABLE_PRODUCTS_DESCRIPTION . " pd, \n\t\t\t\t\t\t\t\t " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,\n\t\t\t\t\t\t\t\t " . TABLE_SPECIALS . " s\n\t\t\t\t\t\t\twhere p.products_status = '1'\n\t\t\t\t\t\t\tand p.products_id = pd.products_id\n\t\t\t\t\t\t\tand pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\t\t\t\t\t\t\tand p.products_id = p2c.products_id\n\t\t\t\t\t\t\tand p2c.categories_id =" . $m_cate_id . " \n\t\t\t\t\t\t\tand p.products_id !=s.products_id \n\t\t\t\t\t\t\tand p.products_id !=" . $real_pid . " \n\t\t\t\t\t\t\tand p.products_price=" . $sp_price . " \n\t\t\t\t\t\t\torder by p.products_ordered desc, pd.products_name\n\t\t\t\t\t\t\tlimit 5"; $sp_products_db = $db->Execute($sp_products_query); $rec_cnt = $sp_products_db->RecordCount(); if ($rec_cnt <= 0) { $sp_products_query2 = "select distinct p.products_id, pd.products_name,p.products_image,p.products_price \n\t\t\t\t\t\t\tfrom " . TABLE_PRODUCTS . " p, \n\t\t\t\t\t\t\t\t " . TABLE_PRODUCTS_DESCRIPTION . " pd, \n\t\t\t\t\t\t\t\t " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,\n\t\t\t\t\t\t\t\t " . TABLE_SPECIALS . " s\n\t\t\t\t\t\t\twhere p.products_status = '1'\n\t\t\t\t\t\t\tand p.products_id = pd.products_id\n\t\t\t\t\t\t\tand pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\t\t\t\t\t\t\tand p.products_id = p2c.products_id\n\t\t\t\t\t\t\tand p2c.categories_id in \n\t\t\t\t\t\t\t (select distinct categories_id from categories \n\t where parent_id=(select parent_id from categories where categories_id=" . $m_cate_id . ")\n\t\t\t\t\t\t\t\t and categories_id!=" . $m_cate_id . ") \n\t\t\t\t\t\t\tand p.products_id !=s.products_id \n\t\t\t\t\t\t\tand p.products_id !=" . $real_pid . " \n\t\t\t\t\t\t\tand p.products_price=" . $sp_price . " \n\t\t\t\t\t\t\torder by p.products_ordered desc, pd.products_name\n\t\t\t\t\t\t\tlimit 5"; $sp_products_db2 = $db->Execute($sp_products_query2); if ($sp_products_db2->RecordCount() > 0) { while ($sp_products_db2->EOF) { $sp_products[] = array('product_name' => $sp_products_db2->fields['products_name'], 'product_image' => $sp_products_db2->fields['products_image'], 'product_price' => $sp_products_db2->fields['products_price'], 'product_url_link' => zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $sp_products_db2->fields['products_id'])); $sp_products_db2->MoveNext(); } } } elseif ($rec_cnt < 5) { while (!$sp_products_db->EOF) { $sp_products[] = array('product_name' => $sp_products_db->fields['products_name'], 'product_image' => $sp_products_db->fields['products_image'], 'product_price' => $sp_products_db->fields['products_price'], 'product_url_link' => zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $sp_products_db->fields['products_id']));
echo zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'enctype="multipart/form-data"'); ?> <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">
$all_wholesale_db = $db->Execute($all_wholesale_split->sql_query); 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_price = $display_specials_price; } 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') {
/** * Method to calculate one time price of attributes for a given item * * @param mixed the product ID of the item to check * @param decimal item quantity * @return decimal the pice of the items attributes * @global object access to the db object */ function attributes_price_onetime_charges($products_id, $qty) { global $db; $attributes_price_onetime = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = "select *\n from " . TABLE_PRODUCTS_ATTRIBUTES . "\n where products_id = '" . (int) $products_id . "'\n and options_id = '" . (int) $option . "'\n and options_values_id = '" . (int) $value . "'"; $attribute_price = $db->Execute($attribute_price_query); // Dual Pricing start if ($_SESSION['customer_id']) { $customers_id = $_SESSION['customer_id']; $customer_check = $db->Execute("select * from " . TABLE_CUSTOMERS . " where customers_id = '{$customers_id}'"); if ($customer_check->fields['customers_whole'] != "0") { $i = $customer_check->fields['customers_whole']; $i--; $options_value_price = (double) $attribute_price->fields['options_values_price_w']; } else { $options_value_price = $attribute_price->fields['options_values_price']; } } else { $options_value_price = $attribute_price->fields['options_values_price']; } // Dual Pricing end $new_attributes_price = 0; $discount_type_id = ''; $sale_maker_discount = ''; // if ($attribute_price->fields['product_attribute_is_free']) { if ($attribute_price->fields['product_attribute_is_free'] == '1' and zen_get_products_price_is_free((int) $products_id)) { // no charge } else { $discount_type_id = ''; $sale_maker_discount = ''; $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty); ////////////////////////////////////////////////// // calculate additional one time charges //// one time charges // attributes_price_onetime if ($attribute_price->fields['attributes_price_onetime'] > 0) { if ((int) $products_id != $products_id) { die('I DO NOT MATCH ' . $products_id); } $attributes_price_onetime += $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']); $attributes_price_onetime += $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); $attributes_price_onetime += $added_charge; } ////////////////////////////////////////////////// } } } return $attributes_price_onetime; }
echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED; ?> </td> // Dual Pricing start <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') {
$products_model = $product_info->fields['products_model']; $products_description = $product_info->fields['products_description']; if ($product_info->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') { $products_image = PRODUCTS_IMAGE_NO_IMAGE; } else { $products_image = $product_info->fields['products_image']; } $products_url = $product_info->fields['products_url']; $products_date_available = $product_info->fields['products_date_available']; $products_date_added = $product_info->fields['products_date_added']; $products_manufacturer = $product_info->fields['manufacturers_name']; $products_weight = $product_info->fields['products_weight']; $products_quantity = $product_info->fields['products_quantity']; $products_qty_box_status = $product_info->fields['products_qty_box_status']; $products_quantity_order_max = $product_info->fields['products_quantity_order_max']; $products_base_price = $currencies->display_price(zen_get_products_base_price((int) $_GET['products_id']), zen_get_tax_rate($product_info->fields['products_tax_class_id'])); $product_is_free = $product_info->fields['product_is_free']; $products_tax_class_id = $product_info->fields['products_tax_class_id']; $module_show_categories = PRODUCT_INFO_CATEGORIES; $module_next_previous = PRODUCT_INFO_PREVIOUS_NEXT; $products_id_current = (int) $_GET['products_id']; $products_discount_type = $product_info->fields['products_discount_type']; $products_discount_type_from = $product_info->fields['products_discount_type_from']; /** * Load product-type-specific main_template_vars */ $prod_type_specific_vars_info = DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars_product_type.php'; if (file_exists($prod_type_specific_vars_info)) { include_once $prod_type_specific_vars_info; } $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_PRODUCT_TYPE_VARS_DOCUMENT_GENERAL_INFO');
var FRIENDLY_URLS='true'; var symbolLeft='<?php echo $currencies->display_symbol_left($_SESSION['currency']); ?> '; var symbolRight=''; var min_quantity=<?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> ; var discount = new Array(); discount[0] ="<?php echo zen_get_products_quantity_order_min($_GET['products_id']); ?> -<?php echo number_format(zen_get_products_base_price($_GET['products_id']), 2); ?> -0-0"; function formatC(s, flag){ if(flag == null){ flag =true; } s = s + ''; if(/[^0-9\.]/.test(s)) return "invalid value"; s=s.replace(/^(\d*)$/,"$1."); s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1"); s=s.replace(".",","); var re=/(\d)(\d{3},)/; while(re.test(s)) s=s.replace(re,"$1,$2"); s=s.replace(/,(\d\d)$/,".$1"); if(flag){