Shop Level Product Edit

Good morning,

I am having a few issues with some targeting. I have create a product called “advertisement” which is visible in the product feed here: https://denverhighriseliving.com/condo-intel/. Here is a screenshot for your reference: https://prnt.sc/k3mhqn. I would like to target only that product to remove the transparent layer on the front, to remove the “read more” button, and to remove the “select to compare” button beneath it. Ultimately this will display third-party advertisements within the client’s product feed.

Thank you!
J

Hello There,

Thanks for writing in!

Do you want something like this?

If that is the case, please add the following CSS code in the X > Theme Options > Global CSS (http://prntscr.com/evui3r)

.woocommerce .post-1688 .entry-wrap,
.woocommerce .post-1688 .entry-wrap:before {
    background-color: transparent !important;
}

.woocommerce .post-1688 .entry-header a.button,
.woocommerce .post-1688 .woocommerce-products-compare-compare-button {
    display: none;
}

Hope this helps. Please let us know how it goes.

Hello,

Thank you for your help. It’s starting to look great. Next, can I remove the word “advertisement,” and make the entire box hyperlink to “#” for now?

Thanks,
J

Hi @weatherstone,

In that case, please add this code to your child theme’s functions.php

function modify_product_url ( $url, $post, $leavename=false ) {
	if ( get_the_ID() == 1743 && x_is_shop() ) {
		$url = '#';
	}
	return $url;
}
add_filter( 'post_link', 'modify_product_url', 10, 3 );

Hope this helps :slight_smile:

Hello,

Unfortunately this code is not working. The product titles for those two items are still there, and the products aren’t wrapped in links. :confused:

Thank you,
J

Hello There,

Please have the code updated and use this:

//Condo Intel Archive - Advertising Links//
function modify_product_url ( $url, $post, $leavename=false ) {
	if ( $post->ID == 1743 || $post->ID == 1688 ) {
		$url = '#';
	}
	return $url;
}
add_filter( 'post_link', 'modify_product_url', 100);

And then since your are using CloudFlare, please login to your CloudFlare account and purge your site cache. I’d recommend that you clear your caching plugin, and disable it during development. Caching plugins are best to turn on only when you’ve finished building the site.

Please let us know how it goes.

Hello,

Thank you for your advice regarding the caching - great to know. After purging everything in CloudFlare, I note that the word “Advertisement” is still displaying on both products in the archive: https://prnt.sc/k43mof. When you click on the product, it disappears, but it needs to be hidden on the archive page.

Thank you!
J

Hi J,

I suggest that you use another approach. Please remove the previously suggested codes and instead add the Javascript code below to Pro > Theme Options > JS:

jQuery('.post-type-archive-product .post-1743 .entry-wrap').remove();
jQuery('.post-type-archive-product .post-1743 a').attr('href', '#');

The first line removes the title. The second line changes the link to #. If you want to change the product you need to also change the code and find the correct ID of the product. In the code above we used the ID 1743. Replace that with the your product ID. To find the ID check the article below:

Instead of the post in the article above you will need to go to the product listing in the admin.

Thank you.

Hello,

Thank you for your response. I followed your instructions to locate the IDs. Unfortunately, after purging the cache I am still seeing the word “Advertisement” on both of the products, neither which seem to have a different link either: https://denverhighriseliving.com/condo-intel/.

Here is your code which I duplicated for the second product listing:

/Advertising Links/
jQuery(’.post-type-archive-product .post-1743 .entry-wrap’).remove();
jQuery(’.post-type-archive-product .post-1743 a’).attr(‘href’, ‘#’);

jQuery(’.post-type-archive-product .post-1688 .entry-wrap’).remove();
jQuery(’.post-type-archive-product .post-1688 a’).attr(‘href’, ‘#’);

Please advise!
J

HI J,

Upon checking, I can see that there is a syntax error in your js code.

Kindly replace the entire code in Theme Options > JS with this

jQuery(document).ready(function(){ 
  jQuery("#woocommerce-product-search-field-0").attr("placeholder", "Search condos by name");
  /*Product Listing: Change "Related Products" to "Related Properties"*/ 
  jQuery(".related.products h2").html("Related Properties");
});

jQuery( document ).ready(function($) {
	$('.woocommerce-products-compare-widget-compare-button').text('Compare');
	$('.woocommerce-products-compare-widget-compare-button').prop('title', 'Add some condos to compare');
});
  
/*Widget Compare Condos Edits*/
jQuery(document).ready (function($){
  $('.woocommerce-mini-cart__empty-message').text('Compare');
   $('.woocommerce-mini-cart__empty-message').text('Select Detailed Condo Intel to view condos in account.');
  $('.no-products').text('Select two to five condos to view and compare their most popular features.');
});

/*Advertising Links*/
jQuery('.post-type-archive-product .post-1743 .entry-wrap').remove();
jQuery('.post-type-archive-product .post-1743 a').attr('href', '#');

jQuery('.post-type-archive-product .post-1688 .entry-wrap').remove();
jQuery('.post-type-archive-product .post-1688 a').attr('href', '#');

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.