Results 1 to 10 of 20

Hybrid View

  1. #1
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: attributes + price factor + special price = incorrect totals

    I can't believe that some form of solution has been found. It seems like it was simple to correct and I can't believe that no one has done this before.. Okay, there may be some "tests" or improvements still to be made around the code to protect the user, but... Sum and total, this is the correction(s) that were needed to go from start to finish on processing a product that is or is not priced by attributes where the attributes can be associated with the special OR a sale (OR combination)... I need someone to confirm/disprove aspects of it, but it became all too clear...

    Anyways, still need the CONSTANT to support transferring the individual attribute related prices over to the checkout_ related path so:

    includes/classes/shopping_cart.php needs to include the below highlighted item which seems to "fix" the issue of at least attributes + price factor + special price coming out to be the incorrect total at checkout.

    Code:
    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'])) {     
         if (!defined('ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL')) define('ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL', 1);  // mc12345678 Added to apply the attribute's price factor and price  factor offset against the provided special price if a special is present  otherwise against the provided price when returning the value from the  function zen_get_attributes_price_factor found in  includes/functions/functions_prices.php 
        reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
           $attributes_price = 0;
    Then working from the end of the file up (so line numbers hold true throughout) in includes/functions/functions_prices.php:
    Find line 1083:
    Code:
          $attributes_price_final += $pre_selected->fields["options_values_price"];
    and replace with:
    Code:
    //      $attributes_price_final += $pre_selected->fields["options_values_price"];
          $attributes_price_final += zen_get_discount_calc($pre_selected->fields["products_id"], $pre_selected->fields["products_attributes_id"], $pre_selected->fields["options_values_price"] + (zen_get_products_price_is_priced_by_attributes($pre_selected->fields["products_id"]) ? zen_products_lookup($pre_selected->fields["products_id"], 'products_price') : 0));
    Then find line 1081:
    Code:
          $attributes_price_final -= $pre_selected->fields["options_values_price"];
    and replace with:
    Code:
    //      $attributes_price_final -= $pre_selected->fields["options_values_price"];
          $attributes_price_final -= zen_get_discount_calc($pre_selected->fields["products_id"], $pre_selected->fields["products_attributes_id"], (zen_get_products_price_is_priced_by_attributes($pre_selected->fields["products_id"]) ? zen_products_lookup($pre_selected->fields["products_id"], 'products_price') : 0) + (zen_get_products_price_is_priced_by_attributes($pre_selected->fields["products_id"]) ? -1 : 1) * $pre_selected->fields["options_values_price"]);
    Line 560:
    Code:
                $calc = ($attributes_amount * $special_price_discount);
    replace with:
    Code:
                $calc = ($attributes_amount * $sale_price_discount);
    Line 539:
    Code:
                if ($special_price_discount != 0) {
                  $calc = ($attributes_amount * $special_price_discount);
    replace with:
    Code:
                if ($sale_price_discount != 0) {
                  $calc = ($attributes_amount * $sale_price_discount);
    At line 501 add/insert the following:
    Code:
        if ($new_products_price != 0) {
          $sale_price_discount = ($new_sale_price != 0 ? ($new_sale_price/$new_products_price) : 1);
        } else {
          $sale_price_discount = '';
        }
    And in includes/modules/YOUR_TEMPLATE/attributes.php (or rather the base install), comment out line 126:
    Code:
    //                      $new_attributes_price = zen_get_discount_calc((int)$_GET['products_id'], true, $new_attributes_price);
    And then are some similar changes that can be made to the admin side. I was working on changing the information presented in the admin attributes_controller such that the discount calculated would be displayed, but I've set that aside for the moment...

    Committed these changes to a ZC PR
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: attributes + price factor + special price = incorrect totals

    Seems that the following ZC commits/pulls might correct both of the issues described here. The commits/pulls are based on changes made from ZC 1.5.5 to ZC 1.5.6 (and corrections made to the first pull to ZC 1.5.6):
    https://github.com/mc12345678/zc-v1-...726016a5fe4b5a
    https://github.com/zencart/zencart/pull/1404/files
    https://github.com/zencart/zencart/pull/2075/files
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. MySQL: setting a new price factor in attributes
    By enquirer66 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 3 Jan 2011, 04:40 PM
  2. Special price on product when cart totals >$100?
    By scrap in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 24 Nov 2010, 06:12 AM
  3. Attributes Price Factor Not Showing on Cart
    By Decostyle in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 15 Apr 2009, 04:17 PM
  4. Including Attribute Price Factor In Base Price Dropdown Menu
    By rob28870 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 1 Oct 2008, 10:14 AM
  5. Price Factor: Based on other attributes?
    By 01011010 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 21 Nov 2007, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg