Does anyone know how to conditionally show this codeONLY when it's a product page otherwise to leave the value blank. Thanks!HTML Code:<?php echo $products_model; ?>
Does anyone know how to conditionally show this codeONLY when it's a product page otherwise to leave the value blank. Thanks!HTML Code:<?php echo $products_model; ?>
I'm not sure I understand the question. Is this specifically related to the Google Trusted Stores topics being discussed above?
Also, if you're not on a product-page, then $products_model would already be blank, and thus nothing would display. So, it's moot.
I think there's a lot more "context" behind your question, and that's needed information before a proper answer can be given to the real issue you're trying to address.
.
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.
Thanks for your response DrByte! Yes my question was in relation to the Google Trusted Store only. I am trying to pass a variable for this:We used the model_id from our site currently for google shopping id (which is why I am trying to figure out how to pass it with the code I posted).HTML Code:gts.push(["google_base_offer_id", "ITEM_GOOGLE_SHOPPING_ID"]);
Thanks!
You asked about how to do something "only" if it's on the product page.
This PHP code will handle that condition:
Code:<?php if ($current_page_base == FILENAME_PRODUCT_INFO) { ?> //put your custom html/script code here <?php } ?>
.
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.
Yes. You could change it to reflect the other constant, or you could add multiple possibilities with normal PHP 'or' logic. Or you could change it to something like:
Code:if (preg_match('/^product_.*?info$/', $current_page_base)) { ...
.
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.
I need help cleaning up the badge code: This is what I have:
The above code works on product page and it insert the Model ID where I want it. However, on non-product page, I still want this line of code:Code:<!-- BEGIN: Google Trusted Stores --> <script type="text/javascript"> var gts = gts || []; gts.push(["id", "11100"]); <?php if (isset($_GET['products_id'])) { ?> gts.push(["google_base_offer_id", "<?php echo $products_model; ?>"]); <?php } ?> gts.push(["google_base_subaccount_id", "144444"]); gts.push(["google_base_country", "US"]); gts.push(["google_base_language", "en"]); (function() { var scheme = (("https:" == document.location.protocol) ? "https://" : "http://"); var gts = document.createElement("script"); gts.type = "text/javascript"; gts.async = true; gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(gts, s); })(); </script> <!-- END: Google Trusted Stores -->only with an empty value. Basically, want a situation to tell the code to display Model ID when the url have product ID but when it's any other page show the Model ID as empty.Code:gts.push(["google_base_offer_id", "ITEM_GOOGLE_SHOPPING_ID"]);
Thanks!
Not sure if this is the most efficient way to do this but I finally have the badge code working and it passed Google's test. Here is my complete code:I am sure the Model ID could have been handled with if else statement but what I tried didn't work.Code:<!-- BEGIN: Google Trusted Stores --> <script type="text/javascript"> var gts = gts || []; gts.push(["id", "11100"]); Replace with your ID <?php if (isset($_GET['products_id'])) { ?> gts.push(["google_base_offer_id", "<?php echo $products_model; ?>"]); <?php } ?> <?php if (!isset($_GET['products_id'])) { ?> gts.push(["google_base_offer_id", ""]); <?php } ?> gts.push(["google_base_subaccount_id", "144444"]); Replace with your ID gts.push(["google_base_country", "US"]); gts.push(["google_base_language", "en"]); (function() { var scheme = (("https:" == document.location.protocol) ? "https://" : "http://"); var gts = document.createElement("script"); gts.type = "text/javascript"; gts.async = true; gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(gts, s); })(); </script> <!-- END: Google Trusted Stores -->
Last edited by BlessIsaacola; 19 Aug 2013 at 02:00 AM. Reason: Clarification
Bookmarks