function zen_get_attributes_price_final($attribute, $qty = 1, $pre_selected, $include_onetime = 'false')
{
    global $db;
    global $cart;
    if ($pre_selected == '' or $attribute != $pre_selected->fields["products_attributes_id"]) {
        $pre_selected = $db->Execute("select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_attributes_id= '" . $attribute . "'");
    } else {
        // use existing select
    }
    // normal attributes price
    if ($pre_selected->fields["price_prefix"] == '-') {
        $attributes_price_final -= $pre_selected->fields["options_values_price"];
    } else {
        $attributes_price_final += $pre_selected->fields["options_values_price"];
    }
    // qty discounts
    $attributes_price_final += zen_get_attributes_qty_prices_onetime($pre_selected->fields["attributes_qty_prices"], $qty);
    // price factor
    $display_normal_price = zen_get_products_actual_price($pre_selected->fields["products_id"]);
    $display_special_price = zen_get_products_special_price($pre_selected->fields["products_id"]);
    $attributes_price_final += zen_get_attributes_price_factor($display_normal_price, $display_special_price, $pre_selected->fields["attributes_price_factor"], $pre_selected->fields["attributes_price_factor_offset"]);
    // per word and letter charges
    if (zen_get_attributes_type($attribute) == PRODUCTS_OPTIONS_TYPE_TEXT) {
        // calc per word or per letter
    }
    // onetime charges
    if ($include_onetime == 'true') {
        $pre_selected_onetime = $pre_selected;
        $attributes_price_final += zen_get_attributes_price_final_onetime($pre_selected->fields["products_attributes_id"], 1, $pre_selected_onetime);
    }
    return $attributes_price_final;
}
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * 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;
 }
function zen_get_attributes_price_final($attribute, $qty = 1, $pre_selected, $include_onetime = 'false')
{
    global $db;
    $attributes_price_final = 0;
    if ($pre_selected == '' or $attribute != $pre_selected->fields["products_attributes_id"]) {
        $pre_selected = $db->Execute("select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_attributes_id= '" . (int) $attribute . "'");
    } else {
        // use existing select
    }
    // normal attributes price
    // Dual Pricing start
    if ($_SESSION['customer_whole']) {
        if ($_SESSION['customer_whole'] != '0') {
            $i = (int) $_SESSION['customer_whole'];
            $i--;
            $option_price_array = $pre_selected->fields['options_values_price_w'];
            $optionprice = explode(",", $option_price_array);
            $options_values_price = (double) $optionprice[$i];
            if ($options_values_price == '0' || $options_values_price == '') {
                $options_values_price = (double) $optionprice[0];
            }
            $the_base_price += $options_values_price;
            if ($options_values_price == '0') {
                $options_values_price = $pre_selected->fields['options_values_price'];
            }
        } else {
            $options_values_price = $pre_selected->fields['options_values_price'];
        }
    } else {
        $options_values_price = $pre_selected->fields['options_values_price'];
    }
    if ($pre_selected->fields["price_prefix"] == '-') {
        $attributes_price_final -= $pre_selected->fields["options_values_price"];
    } else {
        $attributes_price_final += $pre_selected->fields["options_values_price"];
        // Dual Pricing end
    }
    // qty discounts
    $attributes_price_final += zen_get_attributes_qty_prices_onetime($pre_selected->fields["attributes_qty_prices"], $qty);
    // price factor
    $display_normal_price = zen_get_products_actual_price($pre_selected->fields["products_id"]);
    $display_special_price = zen_get_products_special_price($pre_selected->fields["products_id"]);
    $attributes_price_final += zen_get_attributes_price_factor($display_normal_price, $display_special_price, $pre_selected->fields["attributes_price_factor"], $pre_selected->fields["attributes_price_factor_offset"]);
    // per word and letter charges
    if (zen_get_attributes_type($attribute) == PRODUCTS_OPTIONS_TYPE_TEXT) {
        // calc per word or per letter
    }
    // onetime charges
    if ($include_onetime == 'true') {
        $pre_selected_onetime = $pre_selected;
        $attributes_price_final += zen_get_attributes_price_final_onetime($pre_selected->fields["products_attributes_id"], 1, $pre_selected_onetime);
    }
    return $attributes_price_final;
}
Beispiel #5
0
 /**
  * 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;
}
Beispiel #7
0
 function getOrderAttributePrice($pAttributeHash, $pProductHash)
 {
     $ret = 0;
     // normal attributes price
     if ($pAttributeHash["price_prefix"] == '-') {
         $ret -= $pAttributeHash["options_values_price"];
     } else {
         $ret += $pAttributeHash["options_values_price"];
     }
     // qty discounts
     $ret += zen_get_attributes_qty_prices_onetime($pAttributeHash["attributes_qty_prices"], $pProductHash['products_quantity']);
     // price factor
     $display_normal_price = $pProductHash['price'];
     $ret += zen_get_attributes_price_factor($pProductHash['price'], $pProductHash['price'], $pAttributeHash["attributes_price_factor"], $pAttributeHash["attributes_pf_offset"]);
     // per word and letter charges
     if (zen_get_attributes_type($pAttributeHash['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) {
         // calc per word or per letter
     }
     return $ret;
 }