Zen Follower
- Join Date:
- May 2016
- Location:
- Ohio
- Posts:
- 422
- Plugin Contributions:
- 0
Attribute working off regular price not sale price
Yeah it's showing add attrib $1 to every listing, special or no
Started by jmberman on 20 Apr 2018, 10:44 AM · Views: 1,972
Zen Follower
Yeah it's showing add attrib $1 to every listing, special or no
Zen Follower
For now, what I've opted to do is remove +1 Price so the shown attribute lists no price, except upon checkout in the sub-total until we can sort this out :)
I really appreciate the help.
I am also possibly considering hiring someone to redo my store front end to be more professional, as we were just approved for our business license and authorized by our bank underwriters, so I think a better more professional look is in order... if anyone knows of someone available who can really do the job right, please contact me with a job bid, thanks!
Totally Zenned
And did that resolve the +7 for shipping that also became an issue?
I found the code section that causes just the +1 to appear instead of the more involved to determine price. I guess I hadn't fully realized some of the changes that were necessary to further to correct display of price changes.
You know hope you understand that if you want a specific price to be displayed that removing the price factor settings and entering the price for the attribute would accomplish that.
Leads to asking, why is the price factor being used? The answer helps to identify a solution.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Zen Follower
I'm thinking it might be an easy solve if I delete the attribute option altogether, and just mention in my main page news of the day, to add cases to your order, go to our EXTRAS section, and just add them there to buy in quantity... that way the price isn't based on a percentage of the cost of the title, which is real iffy...
Zen Follower
That being said, is there a way to safely delete an attribute that is linked to every product in my store, so I do not have to delete it one at a time?
Zen Follower
So, that's what I wound up doing, just to simplify the problem ;)
Totally Zenned
jmberman:
So, that's what I wound up doing, just to simplify the problem ;)
For others following, if you found the way to delete all occurrences of an attribute associated with many product, it may help them.
That said, so the desired operation was (since little about the business side of this issue has been described): for a product, select an attribute to add a "product" where the that additional product was to be priced based off of the base price of the product being purchased. Further, and perhaps this was where the extra shipping fee was added, that the extra product added some weight to the shipping and that it seems that the amount of weight added caused the additional shipping fee. (shipping setup wasn't fully described.) I believe that the display of information can be modified to meet this goal, but it is/was important to understand what is trying to be done which can also be best accomodated by understanding the goal and idea behind it.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Zen Follower
Yeah it didn't solve it when I removed the weight additions.
Deleting the attribute from all products was easy enough:
Catalog > Option Name Manager, delete the option
Catalog > Option Value Manager, delete the option
Totally Zenned
So, here's a solution to what appears to have been described:
if it doesn't exist, copy includes/modules/attributes.php to includes/modules/YOUR_TEMPLATE/attributes.php where YOUR_TEMPLATE is the name of well your template and is part of the file override structure.
Then using a plain text editor, modify includes/modules/YOUR_TEMPLATE/attributes.php.
Look for this section of code which is expected to be around line 122:
if ($products_options->fields['attributes_discounted'] == 1) {
// apply product discount to attributes if discount is on
// $new_attributes_price = $products_options->fields['options_values_price'];
$new_attributes_price = zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false');
$new_attributes_price = zen_get_discount_calc((int)$_GET['products_id'], true, $new_attributes_price);
} else {
// discount is off do not apply
$new_attributes_price = $products_options->fields['options_values_price'];
}
Below the highlighted line and before the closing curly parentheses, add the following:
$new_attributes_price = zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false', false, $products_options->fields['attributes_discounted']);
so that it will look like this:
if ($products_options->fields['attributes_discounted'] == 1) {
// apply product discount to attributes if discount is on
// $new_attributes_price = $products_options->fields['options_values_price'];
$new_attributes_price = zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false');
$new_attributes_price = zen_get_discount_calc((int)$_GET['products_id'], true, $new_attributes_price);
} else {
// discount is off do not apply
$new_attributes_price = $products_options->fields['options_values_price'];
$new_attributes_price = zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false', false, $products_options->fields['attributes_discounted']);
}
Then in includes/functions/functions_prices.php
again with a plain text editor, find the function: zen_get_attributes_price_final which should be around line 1068.
Modify the function to the following adding the portion(s) that are highlighted:
function zen_get_attributes_price_final($attribute, $qty = 1, $pre_selected, $include_onetime = 'false', $prod_priced_by_attr = false, $attributes_discounted = 1) {
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
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
if ($attributes_discounted == 1) {
$display_normal_price = zen_get_products_actual_price($pre_selected->fields["products_id"]);
} else {
$display_normal_price = zen_get_products_base_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;
}
This should resolve the display issue seen on the product page. I am also working on some other changes to this and similar areas of code to propose which means the parameter list may change in the future, but it appears to work as is for now...
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Tell staff why this post should be reviewed.