$tmp_word_cnt = 0; $tmp_word_cnt_string = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; $tmp_word_cnt = zen_get_word_count($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free']); $tmp_word_price = zen_get_word_count_price($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free'], $products_options->fields['attributes_price_words']); if ($products_options->fields['attributes_price_words'] != 0) { $tmp_html .= TEXT_PER_WORD . $currencies->display_price($products_options->fields['attributes_price_words'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_words_free'] != 0 ? TEXT_WORDS_FREE . $products_options->fields['attributes_price_words_free'] : ''); } if ($tmp_word_cnt != 0 and $tmp_word_price != 0) { $tmp_word_price = $currencies->display_price($tmp_word_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])); $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price; } // calculate letter charges $tmp_letters_cnt = 0; $tmp_letters_cnt_string = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; $tmp_letters_cnt = zen_get_letters_count($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free']); $tmp_letters_price = zen_get_letters_count_price($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free'], $products_options->fields['attributes_price_letters']); if ($products_options->fields['attributes_price_letters'] != 0) { $tmp_html .= TEXT_PER_LETTER . $currencies->display_price($products_options->fields['attributes_price_letters'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_letters_free'] != 0 ? TEXT_LETTERS_FREE . $products_options->fields['attributes_price_letters_free'] : ''); } if ($tmp_letters_cnt != 0 and $tmp_letters_price != 0) { $tmp_letters_price = $currencies->display_price($tmp_letters_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])); $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price; } } } // file uploads // iii 030813 added: support for file fields if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE) { $number_of_uploads++; // $cart->contents[$_GET['products_id']]['attributes_values'][$products_options_name['products_options_id']] $tmp_html = '<input type="file" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" /><br />' . $gBitCustomer->mCart->contents[$prod_id]['attributes_values'][$products_options_names->fields['products_options_id']] . zen_draw_hidden_field(UPLOAD_PREFIX . $number_of_uploads, $products_options_names->fields['products_options_id']) . zen_draw_hidden_field(TEXT_PREFIX . UPLOAD_PREFIX . $number_of_uploads, $gBitCustomer->mCart->contents[$prod_id]['attributes_values'][$products_options_names->fields['products_options_id']]);
/** * Method to calculate price of attributes for a given item * * @param mixed the product ID of the item to check * @return decimal the pice of the items attributes * @global object access to the db object */ function attributes_price($products_id) { global $db, $currencies; $total_attributes_price = 0; $qty = $this->contents[$products_id]['qty']; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attributes_price = 0; $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 { // + or blank adds if ($attribute_price->fields['price_prefix'] == '-') { // calculate proper discount for attributes if ($attribute_price->fields['attributes_discounted'] == '1') { $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); $attributes_price -= $new_attributes_price; } else { $attributes_price -= $attribute_price->fields['options_values_price']; } } else { if ($attribute_price->fields['attributes_discounted'] == '1') { // calculate proper discount for attributes $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); // Dual Pricing start if ($_SESSION['customer_id']) { if ($customer_check->fields['customers_whole'] != "0") { $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price_w'], $qty); } } // Dual Pricing end $attributes_price += $new_attributes_price; } else { $attributes_price += $attribute_price->fields['options_values_price']; } } ////////////////////////////////////////////////// // calculate additional charges // products_options_value_text if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) { $text_words = zen_get_word_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']); $text_letters = zen_get_letters_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']); $attributes_price += $text_letters; $attributes_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']); $attributes_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'], $this->contents[$products_id]['qty']); $attributes_price += $added_charge; } ////////////////////////////////////////////////// } // Validate Attributes if ($attribute_price->fields['attributes_display_only']) { $_SESSION['valid_to_checkout'] = false; $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id']) . ERROR_PRODUCT_OPTION_SELECTION . '<br />'; } /* //// extra testing not required on text attribute this is done in application_top before it gets to the cart if ($attribute_price->fields['attributes_required']) { $_SESSION['valid_to_checkout'] = false; $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id']) . ERROR_PRODUCT_OPTION_SELECTION . '<br />'; } */ $total_attributes_price += zen_round($attributes_price, $currencies->get_decimal_places($_SESSION['currency'])); } } return $total_attributes_price; }
if ($row10a[6] != 0) { $AddedOptionsPrice_OneTime -= $row10a[6] * $prodpricebase; } } $AddedOptionsPrice_OneTime += $row10a[4]; if (ATTRIBUTES_ENABLED_QTY_PRICES == true) { if ($row10a[9] != '' && $row10a[9] != NULL) { $AddedOptionsPrice += get_attributes_quantity_price_for_editorders($row10a[9], $add_product_quantity); } if ($row10a[10] != '' && $row10a[10] != NULL) { $AddedOptionsPrice_OneTime += get_attributes_quantity_price_for_editorders($row10a[10], $add_product_quantity); } } if ($_POST[$sendoptionontv] && ATTRIBUTES_ENABLED_TEXT_PRICES == true) { if ($row10a[11] != 0) { $AddedOptionsPrice += zen_get_letters_count_price($_POST[$sendoptionontv], $row10a[12], $row10a[11]); } if ($row10a[13] != 0) { $AddedOptionsPrice += zen_get_word_count_price($_POST[$sendoptionontv], $row10a[14], $row10a[13]); } } } } } } /* if(IsSet($add_product_options)) { foreach($add_product_options as $option_id => $option_value_id) { $result = $db -> Execute("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_id=pa.options_id LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov ON pov.products_options_values_id=pa.options_values_id WHERE products_id='$add_product_products_id' and options_id=$option_id and options_values_id=$option_value_id"); ###r.l. $row = zen_db_fetch_array($result);
/** * Method to calculate price of attributes for a given item * * @param mixed the product ID of the item to check * @return decimal the pice of the items attributes */ public function attributes_price($products_id) { $attributes_price = 0; $qty = $this->contents[$products_id]['qty']; 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 { // + or blank adds if ($attribute_price->fields['price_prefix'] == '-') { // calculate proper discount for attributes if ($attribute_price->fields['attributes_discounted'] == '1') { $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); $attributes_price -= $new_attributes_price; } else { $attributes_price -= $attribute_price->fields['options_values_price']; } } else { if ($attribute_price->fields['attributes_discounted'] == '1') { // calculate proper discount for attributes $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); $attributes_price += $new_attributes_price; } else { $attributes_price += $attribute_price->fields['options_values_price']; } } ////////////////////////////////////////////////// // calculate additional charges // products_options_value_text if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) { $text_words = zen_get_word_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']); $text_letters = zen_get_letters_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']); $attributes_price += $text_letters; $attributes_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']); $attributes_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'], $this->contents[$products_id]['qty']); $attributes_price += $added_charge; } ////////////////////////////////////////////////// } // Validate Attributes if ($attribute_price->fields['attributes_display_only']) { $this->setSessionVar('valid_to_checkout', false); $cart_errors = $this->getSessionVar('cart_errors'); $cart_errors .= zen_get_products_name($attribute_price->fields['products_id'], $this->getSessionVar('languages_id')) . ERROR_PRODUCT_OPTION_SELECTION . '<br />'; $this->setSessionVar('cart_errors', $cart_errors); } } } return $attributes_price; }
/** * Method to calculate price of attributes for a given item * * @param mixed the product ID of the item to check * @return decimal the pice of the items attributes * @global object access to the db object */ function attributes_price($products_id) { global $db; $attributes_price = 0; $qty = $this->contents[$products_id]['qty']; 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); $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 { // + or blank adds if ($attribute_price->fields['price_prefix'] == '-') { // calculate proper discount for attributes if ($attribute_price->fields['attributes_discounted'] == '1') { $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); $attributes_price -= $new_attributes_price; } else { $attributes_price -= $attribute_price->fields['options_values_price']; } } else { if ($attribute_price->fields['attributes_discounted'] == '1') { // calculate proper discount for attributes $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); $attributes_price += $new_attributes_price; } else { $attributes_price += $attribute_price->fields['options_values_price']; } } ////////////////////////////////////////////////// // calculate additional charges // products_options_value_text if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) { $text_words = zen_get_word_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']); $text_letters = zen_get_letters_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']); $attributes_price += $text_letters; $attributes_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']); $attributes_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'], $this->contents[$products_id]['qty']); $attributes_price += $added_charge; } ////////////////////////////////////////////////// } // Validate Attributes if ($attribute_price->fields['attributes_display_only']) { $_SESSION['valid_to_checkout'] = false; $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id']) . ERROR_PRODUCT_OPTION_SELECTION . '<br />'; } /* //// extra testing not required on text attribute this is done in application_top before it gets to the cart if ($attribute_price->fields['attributes_required']) { $_SESSION['valid_to_checkout'] = false; $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id']) . ERROR_PRODUCT_OPTION_SELECTION . '<br />'; } */ } } foreach ((array) $this->contents[$products_id]['attributes'] as $key => $value) { if (in_array($key, array('BUST', 'WAIST', 'HIPS', 'HOLLOW_TO_HEM'))) { $attributes_price += strval(SIZE_SUBSIDIARY_PRICE); break; } } return $attributes_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; }
function getProductOptions($pSelectedId = NULL, $pCart = NULL, &$productSettings = NULL) { global $currencies; require_once BITCOMMERCE_PKG_PATH . 'includes/functions/html_output.php'; $productOptions = array(); if ($this->loadAttributes()) { $productSettings['zv_display_select_option'] = 0; $productSettings['show_attributes_qty_prices_description'] = 'false'; $productSettings['show_onetime_charges_description'] = 'false'; if (PRODUCTS_OPTIONS_SORT_ORDER == '0') { $options_order_by = ' ORDER BY popt.`products_options_sort_order`'; } else { $options_order_by = ' ORDER BY popt.`products_options_name`'; } $discount_type = $this->getSaleDiscountType(); $discount_amount = $this->getPriceReduction(); $number_of_uploads = 0; foreach (array_keys($this->mOptions) as $optionsId) { $products_options_array = array(); $products_options_value_id = ''; $products_options_details = ''; $products_options_details_noname = ''; $tmp_radio = ''; $tmp_checkbox = ''; $tmp_html = ''; $selected_attribute = false; $tmp_attributes_image = ''; $tmp_attributes_image_row = 0; $productSettings['show_attributes_qty_prices_icon'] = 'false'; $productOptions[$optionsId]['option_values'] = array(); if (!empty($this->mOptions[$optionsId]['values'])) { foreach (array_keys($this->mOptions[$optionsId]['values']) as $valId) { $vals =& $this->mOptions[$optionsId]['values'][$valId]; if (empty($vals['attributes_html_attrib'])) { $vals['attributes_html_attrib'] = ''; } // reset $new_value_price = ''; $price_onetime = ''; $products_options_array[] = array('id' => $vals['products_options_values_id'], 'text' => $vals['products_options_values_name']); if (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '' or STORE_STATUS == '1' or CUSTOMERS_APPROVAL_AUTHORIZATION >= 2 and $_SESSION['customers_authorization'] == '') { $new_options_values_price = 0; } else { // collect price information if it exists $new_value_price = $this->getAttributesPriceFinalRecurring($vals["products_options_values_id"]); $vals['value_price'] = $new_value_price; // reverse negative values for display if ($new_value_price < 0) { $new_value_price = -$new_value_price; $vals['price_prefix'] = '-'; } $price_onetime = ''; if ($vals['attributes_price_onetime'] != 0 || $vals['attributes_pf_onetime'] != 0) { $productSettings['show_onetime_charges_description'] = 'true'; $price_onetime = ' ' . $currencies->display_price($this->getAttributesPriceFinalOnetime($vals["products_options_values_id"]), zen_get_tax_rate($this->mInfo['products_tax_class_id'])); } if (!empty($vals['attributes_qty_prices']) || !empty($vals['attributes_qty_prices_onetime'])) { $productSettings['show_attributes_qty_prices_description'] = 'true'; $productSettings['show_attributes_qty_prices_icon'] = 'true'; } if (!empty($vals['options_values_price']) && (empty($vals['product_attribute_is_free']) && !$this->isFree())) { // show sale maker discount if a percentage $vals['display_price'] = $vals['price_prefix'] . $currencies->display_price($new_value_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); } elseif ($vals['product_attribute_is_free'] == '1' && !$this->isFree()) { // if product_is_free and product_attribute_is_free $vals['display_price'] = TEXT_ATTRIBUTES_PRICE_WAS . $vals['price_prefix'] . $currencies->display_price($new_value_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])) . TEXT_ATTRIBUTE_IS_FREE; } else { // normal price if ($new_value_price == 0) { $vals['display_price'] = ''; } else { $vals['display_price'] = $vals['price_prefix'] . $currencies->display_price($new_value_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); } } if (!empty($vals['display_price'])) { $vals['display_price'] = '( ' . $vals['display_price'] . ($price_onetime ? ' ' . tra('Per Item') . ', ' . $price_onetime . ' ' . tra('One time') : '') . ' )'; } elseif ($price_onetime) { $vals['display_price'] = $price_onetime; } } // approve $products_options_array[sizeof($products_options_array) - 1]['text'] .= $vals['display_price']; // collect weight information if it exists if (SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES == '1' && !empty($vals['products_attributes_wt'])) { $products_options_display_weight = ' (' . $vals['products_attributes_wt_pfix'] . round($vals['products_attributes_wt'], 2) . 'lbs / ' . round($vals['products_attributes_wt'] * 0.4536, 2) . 'kg)'; $products_options_array[sizeof($products_options_array) - 1]['text'] .= $products_options_display_weight; } else { // reset $products_options_display_weight = ''; } if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or count($this->mOptions[$optionsId]) == 1 or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) { $products_options_value_id = $vals['products_options_values_id']; if ($this->mOptions[$optionsId]['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $this->mOptions[$optionsId]['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) { $products_options_details = $vals['products_options_values_name']; } else { // don't show option value name on TEXT or filename $products_options_details = ''; } if ($this->mOptions[$optionsId]['products_options_images_style'] >= 3) { $products_options_details .= $vals['display_price'] . (!empty($vals['products_attributes_wt']) ? '<br />' . $products_options_display_weight : ''); $products_options_details_noname = $vals['display_price'] . (!empty($vals['products_attributes_wt']) ? '<br />' . $products_options_display_weight : ''); } else { $products_options_details .= $vals['display_price'] . (!empty($vals['products_attributes_wt']) ? ' ' . $products_options_display_weight : ''); $products_options_details_noname = $vals['display_price'] . (!empty($vals['products_attributes_wt']) ? ' ' . $products_options_display_weight : ''); } } // =-=-=-=-=-=-=-=-=-=-= radio buttons if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO) { if (is_object($pCart) && $pCart->in_cart($this->mProductsId) && $pCart->contents[$this->mProductsId]['attributes'][$this->mOptions[$optionsId]['products_options_id']] == $vals['products_options_values_id']) { $selected_attribute = $pCart->contents[$this->mProductsId]['attributes'][$this->mOptions[$optionsId]['products_options_id']]; } else { $selected_attribute = $vals['attributes_default'] == '1' ? true : false; // if an error, set to customer setting if (!empty($pSelectedId)) { $selected_attribute = false; reset($pSelectedId); while (list($key, $value) = each($pSelectedId)) { if ($key == $this->mOptions[$optionsId]['products_options_id'] and $value == $vals['products_options_values_id']) { // zen_get_products_name($_POST['products_id']) . $selected_attribute = true; break; } } } else { $selected_attribute = $vals['attributes_default'] == '1'; } } // ignore products_options_images_style as this should be fully controllable via CSS $tmp_radio .= zen_draw_radio_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . ']', $products_options_value_id, $selected_attribute, NULL, "<span class='title'>{$vals['products_options_values_name']}</span> <span class='details'>{$products_options_details_noname}</span>" . (!empty($vals['attributes_image']) ? zen_image(DIR_WS_IMAGES . $vals['attributes_image'], '', '', '', '') : '')); } // =-=-=-=-=-=-=-=-=-=-= checkboxes if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX) { $string = $this->mOptions[$optionsId]['products_options_id'] . '_chk' . $vals['products_options_values_id']; if (is_object($pCart) && $pCart->in_cart($this->mProductsId)) { if ($pCart->contents[$this->mProductsId]['attributes'][$string] == $vals['products_options_values_id']) { $selected_attribute = true; } else { $selected_attribute = false; } } else { // if an error, set to customer setting if (!empty($pSelectedId)) { $selected_attribute = false; reset($pSelectedId); while (list($key, $value) = each($pSelectedId)) { if (is_array($value)) { while (list($kkey, $vvalue) = each($value)) { if ($key == $this->mOptions[$optionsId]['products_options_id'] and $vvalue == $vals['products_options_values_id']) { $selected_attribute = true; break; } } } else { if ($key == $this->mOptions[$optionsId]['products_options_id'] and $value == $vals['products_options_values_id']) { $selected_attribute = true; break; } } } } else { $selected_attribute = $vals['attributes_default'] == '1' ? true : false; } } switch ($this->mOptions[$optionsId]['products_options_images_style']) { case '1': $tmp_checkbox .= '<label>' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], (!empty($vals['attributes_image']) ? zen_image(DIR_WS_IMAGES . $vals['attributes_image']) . ' ' : ' ') . $products_options_details . '</label>'); break; case '2': $tmp_checkbox .= '<label>' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], $products_options_details . (!empty($vals['attributes_image']) ? '<br />' . zen_image(DIR_WS_IMAGES . $vals['attributes_image'], '', '', '', 'hspace="5" vspace="5"') : '') . '</label>'); break; case '3': $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { $tmp_attributes_image .= '</tr><tr>'; $tmp_attributes_image_row = 1; } if (!empty($vals['attributes_image'])) { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], zen_image(DIR_WS_IMAGES . $vals['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $vals['products_options_values_name'] : '') . $products_options_details_noname) . '</td>'; } else { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], $vals['products_options_values_name'] . $products_options_details_noname) . '</td>'; } break; case '4': $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { $tmp_attributes_image .= '</tr><tr>'; $tmp_attributes_image_row = 1; } if (!empty($vals['attributes_image'])) { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . zen_image(DIR_WS_IMAGES . $vals['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $vals['products_options_values_name'] : '') . (!empty($products_options_details_noname) ? '<br />' . $products_options_details_noname : '') . '<br />' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib']) . '</td>'; } else { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . $vals['products_options_values_name'] . (!empty($products_options_details_noname) ? '<br />' . $products_options_details_noname : '') . '<br />' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib']) . '</td>'; } break; case '5': $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { $tmp_attributes_image .= '</tr><tr>'; $tmp_attributes_image_row = 1; } if (!empty($vals['attributes_image'])) { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], zen_image(DIR_WS_IMAGES . $vals['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $vals['products_options_values_name'] : '')) . (!empty($products_options_details_noname) ? '<br />' . $products_options_details_noname : '') . '</td>'; } else { $tmp_attributes_image .= '<td class="smallText" align="center" valign="top">' . zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], $vals['products_options_values_name'] . ($products_options_details_noname != '' ? $products_options_details_noname : '')) . '</td>'; } break; case '0': default: $tmp_checkbox .= zen_draw_checkbox_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . '][' . $products_options_value_id . ']', $products_options_value_id, $selected_attribute, $vals['attributes_html_attrib'], $products_options_details); break; } } // =-=-=-=-=-=-=-=-=-=-= text if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT) { if (is_object($pCart)) { $tmp_value = $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]; $tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $this->mOptions[$optionsId]['products_options_id'] . ']" size="' . $this->mOptions[$optionsId]['products_options_size'] . '" maxlength="' . $this->mOptions[$optionsId]['products_options_length'] . '" value="' . htmlspecialchars($tmp_value) . '" /> '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges $tmp_word_cnt = 0; $tmp_word_cnt_string = $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]; $tmp_word_cnt = zen_get_word_count($tmp_word_cnt_string, $vals['attributes_price_words_free']); $tmp_word_price = zen_get_word_count_price($tmp_word_cnt_string, $vals['attributes_price_words_free'], $vals['attributes_price_words']); if ($vals['attributes_price_words'] != 0) { $tmp_html .= TEXT_PER_WORD . $currencies->display_price($vals['attributes_price_words'], zen_get_tax_rate($this->mInfo['products_tax_class_id'])) . ($vals['attributes_price_words_free'] != 0 ? TEXT_WORDS_FREE . $vals['attributes_price_words_free'] : ''); } if ($tmp_word_cnt != 0 and $tmp_word_price != 0) { $tmp_word_price = $currencies->display_price($tmp_word_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price; } // calculate letter charges $tmp_letters_cnt = 0; $tmp_letters_cnt_string = $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]; $tmp_letters_cnt = zen_get_letters_count($tmp_letters_cnt_string, $vals['attributes_price_letters_free']); $tmp_letters_price = zen_get_letters_count_price($tmp_letters_cnt_string, $vals['attributes_price_letters_free'], $vals['attributes_price_letters']); if ($vals['attributes_price_letters'] != 0) { $tmp_html .= TEXT_PER_LETTER . $currencies->display_price($vals['attributes_price_letters'], zen_get_tax_rate($this->mInfo['products_tax_class_id'])) . ($vals['attributes_price_letters_free'] != 0 ? TEXT_LETTERS_FREE . $vals['attributes_price_letters_free'] : ''); } if ($tmp_letters_cnt != 0 and $tmp_letters_price != 0) { $tmp_letters_price = $currencies->display_price($tmp_letters_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price; } } else { $tmp_html = '<input class="form-control" type="text" name ="id[' . TEXT_PREFIX . $this->mOptions[$optionsId]['products_options_id'] . ']" size="' . $this->mOptions[$optionsId]['products_options_size'] . '" maxlength="' . $this->mOptions[$optionsId]['products_options_length'] . '" />'; $tmp_html .= $products_options_details; } } // =-=-=-=-=-=-=-=-=-=-= file uploads if (is_object($pCart) && $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE) { $number_of_uploads++; $tmp_html = '<input type="file" name="id[' . TEXT_PREFIX . $this->mOptions[$optionsId]['products_options_id'] . ']" /><br />' . $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']] . zen_draw_hidden_field(UPLOAD_PREFIX . $number_of_uploads, $this->mOptions[$optionsId]['products_options_id']) . zen_draw_hidden_field(TEXT_PREFIX . UPLOAD_PREFIX . $number_of_uploads, $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]); $tmp_html .= $products_options_details; } // collect attribute image if it exists and to draw in table below if ($this->mOptions[$optionsId]['products_options_images_style'] == '0' or ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $this->mOptions[$optionsId]['products_options_type'] == '0')) { if (!empty($vals['attributes_image'])) { $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { $tmp_attributes_image .= '</tr><tr>'; $tmp_attributes_image_row = 1; } $tmp_attributes_image .= '<td class="smallText" align="center">' . zen_image(DIR_WS_IMAGES . $vals['attributes_image']) . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br />' . $vals['products_options_values_name'] : '') . '</td>'; } } // Read Only - just for display purposes if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) { $tmp_html .= $products_options_details . '<br />'; } else { $productSettings['zv_display_select_option']++; } $productOptions[$optionsId]['option_values'][$valId]['value_name'] = $vals['products_options_values_name']; $productOptions[$optionsId]['option_values'][$valId]['value_price'] = $vals['value_price']; // default // find default attribute if set to for default dropdown if ($vals['attributes_default'] == '1') { $selected_attribute = $vals['products_options_values_id']; } } } $commentPosition = !empty($this->mOptions[$optionsId]['products_options_comment_position']) && $this->mOptions[$optionsId]['products_options_comment_position'] == '1' ? '1' : '0'; switch (true) { // text case $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT: if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = $tmp_html; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; // checkbox // checkbox case $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX: if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = '<div class="checkbox">' . $tmp_checkbox . '</div>'; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; // radio buttons // radio buttons case $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO: if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = $tmp_radio; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; // file upload // file upload case $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE: if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = $tmp_html; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; // READONLY // READONLY case $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY: $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; $productOptions[$optionsId]['menu'] = $tmp_html; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; // dropdownmenu auto switch to selected radio button display // dropdownmenu auto switch to selected radio button display case !empty($this->mOptions[$optionsId]['values']) && count($this->mOptions[$optionsId]['values']) == 1: if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = zen_draw_radio_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . ']', $products_options_value_id, 'selected', NULL, $products_options_details); $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; default: // normal dropdown menu display if (is_object($pCart) && isset($pCart->contents[$this->mProductsId]['attributes'][$this->mOptions[$optionsId]['products_options_id']])) { $selected_attribute = $pCart->contents[$this->mProductsId]['attributes'][$this->mOptions[$optionsId]['products_options_id']]; } else { // selected set above // echo 'Type ' . $this->mOptions[$optionsId]['products_options_type'] . '<br />'; } if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; } else { $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; } $productOptions[$optionsId]['menu'] = zen_draw_pull_down_menu('id[' . $this->mOptions[$optionsId]['products_options_id'] . ']', $products_options_array, $selected_attribute, $this->mOptions[$optionsId]['products_options_html_attrib']); $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; break; } // attributes images table $productOptions[$optionsId]['attributes_image'] = $tmp_attributes_image; } } return $productOptions; }