Home › Forums › WoodMart support forum › Replace add to cart button with JS
Replace add to cart button with JS
- This topic has 9 replies, 2 voices, and was last updated 12 months ago by
Hung Pham.
-
AuthorPosts
-
February 26, 2024 at 11:25 pm #544042
v1ppers0nnParticipantHi, i want to remove the “a href” of the “add to cart” button, because this generate thousand of links. For example:
– https://magherbs.com/problemi-i-zabolyavaniya/bolki-v-stavite/?add-to-cart=28843
– https://magherbs.com/hranitelni-dobavki/lipozomni/?add-to-cart=28843
– https://magherbs.com/?add-to-cart=28843This is really bad for SEO.
Is possible to make the add to cart with JS or data-href?
February 27, 2024 at 1:47 pm #544249
Hung PhamKeymasterHi v1ppers0nn,
Thanks for reaching to us.
Do you want to remove this part of href tag https://prnt.sc/cBCxLbnnrBbA?
If so, then you can’t add product to the cart.
Regards,
February 27, 2024 at 2:28 pm #544284
v1ppers0nnParticipantCan you help me to make this:
There are many options for hiding external links, one of them is Clever Hide. This is an intuitive way through which without using Base64 or other decoders given links are available to users but not considered links from robots.
1. Placing a hidden link.
2. The link in the page is placed as follows:
<span class=”clever-link”
data-link=”http://anylink.com>”>anylink.com</span>3. Paste the JS loader code.
JavaScript code that needs to be loaded after loading the The DOM tree:$(document).ready(function() {
$(‘.clever-link’).click(function(){window.open($(this).data(‘link’),
“_self”);return false;});
});This is an example based on the jQuery library. This feature should to be loaded on any page that contains span elements with a class clever-link.
It is important that the function loads after all are fully loaded HTML elements.
4. Setting the CSS style for the correct visualization.
In order for the span element to appear as a link, it needs to be added the following CSS style:
span.clever-link {
text-decoration: underline;
cursor: pointer;
/* other link styling to match site design */
}5. Additional clarifications.
It actually represents a simple span element which on click performs a JavaScript redirect to an element.Final goal:
The link is available to users but invisible to bots
search engines-
This reply was modified 1 year ago by
v1ppers0nn.
February 28, 2024 at 9:02 am #544516
Hung PhamKeymasterHi v1ppers0nn,
Changing like this would require complicated customization, which is out of basic support. Thanks for understanding our limitation.
Regards,
February 28, 2024 at 10:11 am #544537
v1ppers0nnParticipantCan you give me a price for this customization?
February 28, 2024 at 11:49 am #544593
Hung PhamKeymasterHi v1ppers0nn,
Currently, we do not offer customization.
Thanks for your understanding.
Regards,
February 28, 2024 at 11:50 am #544599
v1ppers0nnParticipantSo how can i delete completly the button in the category pages? Not hide it with CSS.
February 28, 2024 at 2:36 pm #544671
Hung PhamKeymasterHi v1ppers0nn,
Unfortunately, it is not possible. Such modification requires complicated of changing HTML structure Woocommerce code customization which is not covered by our support.
Best Regards.
March 5, 2024 at 9:56 am #546219
v1ppers0nnParticipantHi, i found an method to change the url of add to cart, but i cant make it on the homepage. Do you know what is the tag for homepage? I am usign this:
add_filter(‘woocommerce_is_purchasable’, ‘hide_add_to_cart_category’, 99 );function hide_add_to_cart_category ($hide) {
//short-hand version
//return $hide = is_product_category() ? false : true;if ( is_product_category() || is_shop()) {
$hide = false;
} else {
$hide = true;
}return $hide;
}Is working on category pages, but i want also in homepage.
Thanks.
March 6, 2024 at 12:43 pm #546595
Hung PhamKeymasterHi v1ppers0nn,
Thanks for your patience.
According to the code, I see it currently applies to Shop and Product categories page. However, customization is out of our support scope. Please contact who wrote this code for further assistance.
Thanks for your understanding.
Best Regards.
-
This reply was modified 1 year ago by
-
AuthorPosts
- You must be logged in to create new topics. Login / Register