$off_image_delete = true; ?> <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css"> <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script> <script language="javascript"><!-- var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?> ",scBTNMODE_CUSTOMBLUE); //--></script> <script language="javascript"><!-- var tax_rates = new Array(); <?php for ($i = 0, $n = sizeof($tax_class_array); $i < $n; $i++) { if ($tax_class_array[$i]['id'] > 0) { echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . zen_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; } } ?> function doRound(x, places) { return Math.round(x * Math.pow(10, places)) / Math.pow(10, places); } function getTaxRate() { var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex; var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value; if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) { return tax_rates[parameterVal]; } else {
function eo_get_new_product($product_id, $product_qty = 1, $product_options = array(), $use_specials = true) { global $db; $product_id = (int) $product_id; $product_qty = (double) $product_qty; $retval = array('id' => $product_id, 'qty' => $product_qty); $query = $db->Execute('SELECT `p`.`products_id`, `p`.`master_categories_id`, `p`.`products_status`, ' . '`pd`.`products_name`, `p`.`products_model`, `p`.`products_image`, `p`.`products_price`, ' . '`p`.`products_weight`, `p`.`products_tax_class_id`, `p`.`manufacturers_id`, ' . '`p`.`products_quantity_order_min`, `p`.`products_quantity_order_units`, ' . '`p`.`products_quantity_order_max`, `p`.`product_is_free`, `p`.`products_virtual`, ' . '`p`.`products_discount_type`, `p`.`products_discount_type_from`, ' . '`p`.`products_priced_by_attribute`, `p`.`product_is_always_free_shipping` ' . 'FROM `' . TABLE_PRODUCTS . '` AS `p`, `' . TABLE_PRODUCTS_DESCRIPTION . '` AS `pd` ' . 'WHERE `p`.`products_id`=\'' . (int) $product_id . '\' ' . 'AND `pd`.`products_id`=`p`.`products_id` ' . 'AND `pd`.`language_id`=\'' . (int) $_SESSION['languages_id'] . '\''); if (!$query->EOF) { // Handle common fields $retval = array_merge($retval, array('name' => $query->fields['products_name'], 'model' => $query->fields['products_model'], 'price' => $query->fields['products_price'], 'products_discount_type' => $query->fields['products_discount_type'], 'products_discount_type_from' => $query->fields['products_discount_type_from'], 'products_priced_by_attribute' => $query->fields['products_priced_by_attribute'], 'product_is_free' => $query->fields['product_is_free'], 'products_virtual' => $query->fields['products_virtual'], 'product_is_always_free_shipping' => $query->fields['product_is_always_free_shipping'], 'tax' => number_format(zen_get_tax_rate_value($query->fields['products_tax_class_id']), 4), 'tax_description' => zen_get_tax_description($query->fields['products_tax_class_id']))); // Handle pricing $special_price = zen_get_products_special_price($product_id); if ($use_specials && $special_price && $retval['products_priced_by_attribute'] == 0) { $retval['price'] = $special_price; } else { $special_price = 0; } if (zen_get_products_price_is_free($product_id)) { // no charge $retval['price'] = 0; } // adjust price for discounts when priced by attribute if ($retval['products_priced_by_attribute'] == '1' && zen_has_product_attributes($product_id, 'false')) { // reset for priced by attributes if ($special_price) { $retval['price'] = $special_price; } else { $retval['price'] = $query->fields['products_price']; // START MARKUP if (isset($GLOBALS['priceMarkup'])) { $retval['price'] = $GLOBALS['priceMarkup']->calculatePrice($product_id, $query->fields['manufacturers_id'], $query->fields['master_categories_id'], $retval['price']); } // END MARKUP } } else { // discount qty pricing if ($retval['products_discount_type'] != '0') { $retval['price'] = zen_get_products_discount_price_qty($product_id, $retval['qty']); } // START MARKUP if (isset($GLOBALS['priceMarkup'])) { $retval['price'] = $GLOBALS['priceMarkup']->calculatePrice($product_id, $query->fields['manufacturers_id'], $query->fields['master_categories_id'], $retval['price']); } // END MARKUP } unset($special_price); $retval['onetime_charges'] = 0; $retval['final_price'] = $retval['price']; } // Handle attributes if (is_array($product_options) && count($product_options > 0)) { $retval['attributes'] = array(); include_once DIR_WS_CLASSES . 'attributes.php'; $attributes = new attributes(); foreach ($product_options as $option_id => $details) { $attr = array(); switch ($details['type']) { case PRODUCTS_OPTIONS_TYPE_TEXT: case PRODUCTS_OPTIONS_TYPE_FILE: $attr['option_id'] = $option_id; $attr['value'] = $details['value']; if ($attr['value'] == '') { continue 2; } // There should only be one text per name..... $get_attr_id = $attributes->get_attributes_by_option($product_id, $option_id); if (count($get_attr_id) == 1) { $details['value'] = $get_attr_id[0]['products_attributes_id']; } unset($get_attr_id); break; case PRODUCTS_OPTIONS_TYPE_CHECKBOX: if (!array_key_exists('value', $details)) { continue 2; } $tmp_id = array_shift($details['value']); foreach ($details['value'] as $attribute_id) { // We only get here if more than one checkbox per // option was selected. $tmp = $attributes->get_attribute_by_id($attribute_id, 'order'); $retval['attributes'][] = $tmp; // Handle pricing $prices = eo_get_product_attribute_prices($attribute_id, $tmp['value'], $product_qty); unset($tmp); if (!$query->EOF) { $retval['onetime_charges'] += $prices['onetime_charges']; $retval['final_price'] += $prices['price']; } } $details['value'] = $tmp_id; $attr = $attributes->get_attribute_by_id($details['value'], 'order'); unset($attribute_id); unset($attribute_value); unset($tmp_id); break; default: $attr = $attributes->get_attribute_by_id($details['value'], 'order'); } $retval['attributes'][] = $attr; if (!$query->EOF) { // Handle pricing $prices = eo_get_product_attribute_prices($details['value'], $attr['value'], $product_qty); $retval['onetime_charges'] += $prices['onetime_charges']; $retval['final_price'] += $prices['price']; } } unset($query, $attr, $prices, $option_id, $details); } return $retval; }