Forums / Bug Reports / [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

[Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

Locked

Views: 1,681

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
3 Mar 2010, 4:28 AM
#1
jrayfield avatar

jrayfield

New Zenner

Join Date:
Dec 2008
Posts:
81
Plugin Contributions:
0

[Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

I'm not sure if this is a 'bug' or not, but it looks like one....

Most of my Sub-Categories have multiple products. For these product pages, the Title MetaTags are correct.

However, I have one Sub-Category under which there is only one product. I have the configuration for my site set such that if there is only one product in a Sub-Category, then it will show the product page for that product.

For this particular product page, the Title MetaTag shows "It's Free" in the Title, even though I have that product set to "Call For Price". Setting "Meta Tags - Set Price In Title" to 0 (off) makes no difference. The phrase "It's Free" always shows in the Title MetaTag for this product page.

I found that if I delete "META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT" from the statement in line (approximately) 236, of the meta_tags.php file, which is located in /includes/modules/ subdirectory, then this prevents this phrase "It's Free" from being displayed.

It appears that this phrase, held in the variable "META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT" is being displayed incorrectly, due to a problem in the code around line 236 of that meta_tags.php file.

I don't know PHP programming well enough to fix this problem (other than to take the variable "META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT" out of the line, as I did. Of course, this would also 'break' the code, if I do want that variable to be displayed on a product page.

Can someone help me out to fix this problem (correctly)?

John Rayfield, Jr.
https://www.rayfield.net

3 Mar 2010, 5:00 AM
#2
jrayfield avatar

jrayfield

New Zenner

Join Date:
Dec 2008
Posts:
81
Plugin Contributions:
0

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

Here's a bit more....

I got 'brave' and decided to try this:

Line 236 (approximately) was this:

    $meta_products_price = ($product_info_metatags->fields['metatags_price_status'] == '1' ? SECONDARY_SECTION . ($product_info_metatags->fields['products_price_sorter'] > 0 ? $currencies->display_price($product_info_metatags->fields['products_price_sorter'], zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT) : '');

I added an conditional section, so that this line is only 'created' if the META_TAG_INCLUDE_PRICE variable is set to '1' - like this:

  if (META_TAG_INCLUDE_PRICE == '1') {
    $meta_products_price = ($product_info_metatags->fields['metatags_price_status'] == '1' ? SECONDARY_SECTION . ($product_info_metatags->fields['products_price_sorter'] > 0 ? $currencies->display_price($product_info_metatags->fields['products_price_sorter'], zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT) : '');
  }

I do see a problem with this - the condition is based on whether or not the price should be included in the Title MetaTag, not based necessarily on whether the price really is free or not.

I need to base this condition upon whether or not that particular item is free or not. But, I can't find the proper variable to use for this condition.

Any ideas?

John Rayfield, Jr.
https://www.rayfield.net

3 Mar 2010, 5:48 AM
#3
jrayfield avatar

jrayfield

New Zenner

Join Date:
Dec 2008
Posts:
81
Plugin Contributions:
0

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

I tried something else....

I replaced this line of code, at (approximately) line 230:

    $meta_products_price = ($product_info_metatags->fields['metatags_price_status'] == '1' ? SECONDARY_SECTION . ($product_info_metatags->fields['products_price_sorter'] > 0 ? $currencies->display_price($product_info_metatags->fields['products_price_sorter'], zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT) : '');

.....with this block of code (most of which came from lines 264 to 276):

  if (META_TAG_INCLUDE_PRICE == '1') {
    if ($product_info_metatags->fields['product_is_free'] != '1') {
      if (zen_check_show_prices() == true) {
        $meta_products_price = zen_get_products_actual_price($product_info_metatags->fields['products_id']);
        $prod_is_call_and_no_price = ($product_info_metatags->fields['product_is_call'] == '1' && $meta_products_price == 0);
        $meta_products_price = (!$prod_is_call_and_no_price ? SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($product_info_metatags->fields['products_tax_class_id'])) : '');
      }
    } else {
      $meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
    }
  } else {
    $meta_products_price = '';
  }

This seems to work....but I'm not 100% sure that I didn't 'break' something else.

John Rayfield, Jr.
https://www.rayfield.net

3 Mar 2010, 10:18 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

JRayfield:

For this particular product page, the Title MetaTag shows "It's Free" in the Title, even though I have that product set to "Call For Price". Setting "Meta Tags - Set Price In Title" to 0 (off) makes no difference. The phrase "It's Free" always shows in the Title MetaTag for this product page.
I can't replicate the problem you're reporting, using a clean fresh install of v1.3.8a and using a demo product such as found in the demo data in the Hardware->Keyboards category.

What's unique about how you've configured that product and how you've configured your various store settings?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Mar 2010, 2:56 PM
#5
jrayfield avatar

jrayfield

New Zenner

Join Date:
Dec 2008
Posts:
81
Plugin Contributions:
0

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

Nothing's really unique about the product setup. It's not free, I have Call For Price checked, and the price is set to 0. I do have Keywords and Description set for this product and Store Status is set to '2' (Showcase with Prices).

I do have other add-ons installed, so maybe one of them is causing this odd behavior.

But, making the changes that I did, has corrected the problem.

I've done a lot of programming in the past, but not with PHP, so I'm not real familiar with the syntax of PHP, yet. But, I did spend some time last night looking over the code in meta_tags.php and it appears that the code is written in such a way that if Keywords and Descriptions are set up for a product, and Show Prices is enabled (zen_check_show_prices = true), then the Title MetaTag for that page is going to show the META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT. There is no other conditional statement to prevent this variable from being 'displayed'.

The code to which I'm referring is at lines 225 to 238 in the original meta_tags.php file (/includes/modules/meta_tags.php).

John Rayfield, Jr.
https://www.rayfield.net

3 Mar 2010, 3:23 PM
#6
jrayfield avatar

jrayfield

New Zenner

Join Date:
Dec 2008
Posts:
81
Plugin Contributions:
0

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

Looking more at this code, here's what I see...

The line that creates $meta_products_price, includes the variable META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT. There needs to be a conditional statement to make sure that this line is NOT used if the product is NOT free. Such a condition does not exist in the original code.

So, I made a copy of the line that creates $meta_products_price, but did not include the META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT variable at the end of that line.

I then have two statements to create $meta_products_price - one for free products and one for products that are not free.

Then, I added this condition, before those statements:

if ($product_info_metatags->fields['product_is_free'] != '1')

Now, if the product is free, then the Title MetaTag created will include "It's Free". If the product is not free, then that statement is not included. If the product has a price, then the price is shown.

John Rayfield, Jr.
https://www.rayfield.net

4 Mar 2010, 9:34 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

Okay, I triggered what I think you've got, and found the solution. No code changes required.

Symptom: "It's Free" showing in TITLE metatag when product is Call For Price

Conditions:
a) product is marked as Call For Price
b) product price is set to 0
c) metatag keywords and descriptions contain custom text
d) metatag title "price" flag set to Yes for this product

Solution:
If you simply go to the metatags page for that product, and under the "Mark What the Product's Meta Tag Title Should Include" section set Price=No, then it won't show the "It's Free" on you.

The "It's Free" text is being triggered because you have the product price set to 0, and have the metatags switch for that product set to include the price in the metatag title.

NOTE: The default setting is originally "Price = No" already, so it should have been set like that automatically unless you changed the setting or the default.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Mar 2010, 9:36 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Not a Bug] "It's Free" Showing In Title MetaTag When It Should Not

JRayfield:

Most of my Sub-Categories have multiple products. For these product pages, the Title MetaTags are correct.

However, I have one Sub-Category under which there is only one product. I have the configuration for my site set such that if there is only one product in a Sub-Category, then it will show the product page for that product.
FYI - I haven't seen anything that would make this particular fact have any particular bearing on the symptoms you described. I'm pretty sure it's not a contributing factor.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.