WooCommerce One Page Checkout - Hide Product Attribute Colon - woocommerce

I'm currently using WooCommerce OnePage CheckOut
I'd like to remove the "attribute :" text from the product list.
I copied product-list.php
FROM: "/wp-content/plugins/woocommerce-one-page-checkout/templates/checkout/"
TO: "/public_html/wp-content/themes/my-theme-child/woocommerce/checkout/product-list.php"
Modified the "/public_html/wp-content/themes/my-theme-child/woocommerce/checkout/product-list.php" file
FROM:
<span class="attributes"><?php echo esc_html( apply_filters( 'woocommerce_attribute', $attribute_string, $product->get_variation_attributes(), $product ) ); ?></span>
TO:
<span class="attributes"><?php echo esc_html( apply_filters( 'woocommerce_attribute', str_replace ("attribute: ","",$attribute_string), $product->get_variation_attributes(), $product ) ); ?></span>
Once I saved the file, seems the changes not reflected on the page?
Did I miss anything here?
Thanks

It turns out to be caching issue sigh
All good now
Another option is to update /wp-content/themes/my-theme-child/functions.php
add_filter( 'woocommerce_attribute_label', 'remove_attribute_label');
function remove_attribute_label() {
return "";
}
But with this option, the colon still exists...

Related

How to change "Read more" button text on Wordpress posts

After updating plugins, my "Read more" button on posts changed it's name. In Latvian language it was "Lasīt vairāk", while in Russian "Читать дальше". It's just in plain English. The image of how it looks now is via this link. Plugin updates basically wiped out the padding and the name of the button.
Tried modifying functions.php with
// Replaces the excerpt "Read More" text by a link
function modify_read_more_link() {
return '<a class="read-article" href="' . get_permalink() . '">Your Read
More Link Text</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );
// Replaces the excerpt "Read More" text by a link
function new_excerpt_more($more) {
global $post;
return '<a class="read-article" href="'. get_permalink($post->ID) . '">
Read the full article...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
Tried loco translate and modifying internal translations of Elementor-related plugins. The closest I could get is that the elements is named "eael-post-elements-readmore-btn". Styling the element with CSS doesn't do anything. Padding or margin do not work. It's locked. Can anyone provide a hint?
The button should be in Latvian and Russian language, not in English.
PS. Figured that it is Elementor posts plugin related overriding functions.php and translators as well. At this moment, can't figure how to CSS this thing. Stays static.
Add this in functions.php:
function develop_custom_excerpt_more($more) {
global $post;
// edit here if you like
return '... <a class="excerpt-read-more" href="'. get_permalink( $post->ID ) . '" title="'. __( 'Read ', 'domain_name' ) . esc_attr( get_the_title( $post->ID ) ).'">'. __( 'Show more »', 'domain_name' ) .'</a>';
}
add_filter( 'excerpt_more', 'develop_custom_excerpt_more' );
Figured that it is Elementor posts plugin related overriding functions.php and translators as well. The eael-post-elements-readmore-btn was not changing in padding nor in margin because line-height which by default is set to 1 could not allow space for expansion.

Add New “View Product” button below add to cart button in WooCommerce archives pages [duplicate]

I'd like to add a button next to "Add to Cart" on the product page that adds "-sample" to the product URL when clicked.
Example:
You're viewing Product 1's page and the URL is "http://www.example.com/shop/product-1/"
When you click on the button, it adds "-sample" to the URL
"http://www.example.com/shop/product-1-sample/"
How can I achieve this?
Thanks
For woocommerce 3+ (only):
In woocommerce 3 you will use woocommerce_after_shop_loop_item action hook instead, as the hook woocommerce_after_add_to_cart_button will not work anymore.
add_action( 'woocommerce_after_add_to_cart_button', 'add_custom_button', 10, 0 );
function add_custom_button() {
global $product;
$product_link = $product->get_permalink();
$sample_link = substr($product_link, 0, -1) . '-sample/';
echo '<a class="button alt btn-sample" href="' . esc_url( $sample_link ) .'">' . __( "Get a sample", "my_theme_slug" ) . '</a>';
}
Code goes on function.php file of your active child theme (or active theme). Tested and works.
Before woocommerce 3:
This is possible using hook woocommerce_after_add_to_cart_button to add your additional button on product pages, using this custom function:
add_action( 'woocommerce_after_add_to_cart_button', 'add_custom_button', 10, 0 );
function add_custom_button() {
global $product;
$product_link = get_permalink( get_the_id() );
$sample_link = substr($product_link, 0, -1) . '-sample/';
echo '<a class="button alt btn-sample" href="' . esc_url( $sample_link ) .'">' . __( "Get a sample", "my_theme_slug" ) . '</a>';
}
This code goes on function.php file of your active child theme or theme.
This code is tested and fully functional.
Based on this: Add a button after add to cart and redirect it to some custom link in WooCommerce
And this: PHP - How to remove all specific characters at the end of a string?
It's been a long time since the original question, but here's a recent update that works for me, WooCommerce 6.3.1:
/* WooCommerce customization */
add_action( 'woocommerce_after_shop_loop_item', 'custom_select_link', 11 );
function custom_select_link() {
global $product;
// Custom "Select" button.
echo '<a class="custom-button" href="' . esc_url( get_permalink( $product->id ) ) . '"><button class="custom-button"> </button></a>';
}
This answer cites an answer in wordpress.stackexchange.

Woocommerce Attributes Link

i would to modify the single product page in my shop site.
I have to remove links from attribute list in the Additional Information Tab.
I found this html is called in this page: /woocommerce/templates/single-product/product-attributes.php
In this part of code:
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
Do you know if exist another argument instead “value” for example “slug” or “name”?
If not, how can modify the call to show only value without link?
Thank’s
Add the follows code snippet in your active theme's functions.php -
function filter_woocommerce_attribute_value( $value ) {
return preg_replace( '#<a.*?>([^>]*)</a>#i', '$1', $value );
}
add_filter( 'woocommerce_attribute', 'filter_woocommerce_attribute_value', 99 );

Open WooCommerce External Products in New Tab

I'm trying to customize WooCommerce external product links to open in new tabs...
This is my try:
added a filter to the WordPress theme functions.php file as the following:
add_filter( 'woocommerce_product_add_to_cart_url', 'woocommerce_externalProducts_openInNewTab' );
function woocommerce_externalProducts_openInNewTab($product_url) {
global $product;
if ( $product->is_type('external') ) {
$product_url = $product->get_product_url() . '"target="_blank""';
}
return $product_url;
}
What did I missed?
what you're currently doing is wrong... get_product_url is named as what it do. It will give you the url... not the html anchor that has the url, but just the url.. so you're just adding some text to the url.. that's what you are doing...
One solution is given by #Ash Patel. You can change the markup by using templates... just navigate to your plugin folder and look for this file.. woocommerce\templates\single-product\add-to-cart\external.php. You can find instructions inside it.
Now, sometimes, we don't like editing templates... especially if it's just minor edits like this...
Below code will do it the way you want it... just paste this code in your theme's functions.php.
remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
add_action( 'woocommerce_external_add_to_cart', 'rei_external_add_to_cart', 30 );
function rei_external_add_to_cart(){
global $product;
if ( ! $product->add_to_cart_url() ) {
return;
}
$product_url = $product->add_to_cart_url();
$button_text = $product->single_add_to_cart_text();
do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<p class="cart">
<?php echo esc_html( $button_text ); ?>
</p>
<?php do_action( 'woocommerce_after_add_to_cart_button' );
}
Here is how you add target="_blank" to the links on archive pages:
function ns_open_in_new_tab($args, $product)
{
if( $product->is_type('external') ) {
// Inject target="_blank" into the attributes array
$args['attributes']['target'] = '_blank';
}
return $args;
}
add_filter( 'woocommerce_loop_add_to_cart_args', 'ns_open_in_new_tab', 10, 2 );
Replace ns_ part with your own namespace abbreviation.
Remove above funtion from function.php:
Use plugin files from Template folder by Template Overwrite method and then
follow below path:
woocommerce\templates\single-product\add-to-cart\external.php
open external.php where there is a tag, apply target="_blank".
it will work.

How to remove the author name on wordpress blog posts?

I want to remove the author name from wordpress blog posts . Also I dont want to delete the author name becoz I use different author names from admin side.
WP v4.1.2
Edit content-single.php:
Appearance->Editor->content-single.php
<div class="entry-meta">
<?php // twentyeleven_posted_on(); ?>
</div><!-- .entry-meta -->
Comment the middle line "twentyeleven_posted_on();" like above
Title line on post saying: Published By AUTHOR on DATE will not be displayed
OR (less recommended as it effects a wider scale)
functions.php
COMMENTED LINE get_the_author()
function twentyeleven_posted_on() {
printf( __( '<span class="sep">Posted on </span><time class="entry-date" datetime="%3$s" pubdate>%4$s</time><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) )/*,
get_the_author()*/
);
}
Open the single.php file of your current theme through your ftp client or from Dashboard -->Appearance -->Editor
Delete this code :
<span class="meta_author"><?php the_author(); ?></span>
Hope this helps
You can comment/delete the line where author name is printed.
<span class="meta_author"><?php the_author(); ?></span>
I removed the author names from posts and search results on a site built with The7 theme by adding this custom CSS:
a.author.vcard {
display: none;
}
The other answers here that relate to the PHP code of WP are true, but alternatively this can also be done by modifying the CSS code of the site.
Under the main stylesheet file (style.css), you can add this definition:
.blog-title-body SPAN {
display:none !important;
}
This specifically will hide both the author name AND the category name under the header of the post page (the post name).
If you want to remove only the category name, for example, you can put in the following definition:
.blog-title-body SPAN.cat-links {
display:none !important;
}
NOTE:
be sure to always make a backup copy of every built-in file on WP site that you modify!!
It is also highly recommended to make an entire site backup periodically, with and without relation to modifications and changes.

Resources