Change view button text in Woocommerce My account orders table - php

I would like to customize My account > Orders page, changing from action column, the "view" button text to "view tickets" in the Orders list table.
Is it possible to do it only on My account > Orders page?
Here is a screenshot for clarifications:

To rename My account > Orders: "view" action button text, use the following:
// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
$actions['view']['name'] = __( 'View ticket', 'woocommerce' );
return $actions;
}
To Rename My account "Orders" menu item, use the following (if needed):
// Rename My account "Orders" menu item
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_orders_menu_item', 22, 1 );
function rename_my_account_orders_menu_item( $items ) {
$items['orders'] = __("Ticket Orders", "woocommerce");
return $items;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
If you need to target only My account > "orders" table, use is_wc_endpoint_url('orders') conditional tag:
// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
if( is_wc_endpoint_url( 'orders' ) )
$actions['view']['name'] = __( 'View ticket', 'woocommerce' );
return $actions;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.

Related

How to change place order button text for paypal in WooCommerce checkout

I have a question about changing text of place_order.
Check out page will reload form by update_checkout Event, So the place_order text will change back to original text ‘proceed to Paypal’.
I've tried to use Jquery and function hook to change text but still change back.
function woo_custom_order_button_text() {
return __( 'Your new button text here', 'woocommerce' );
}
How can I change the text of #place_order by not disable the update_checkout Event?
To change the place order button text when Paypal is the chosen payment gateway use the following:
add_filter( 'gettext', 'change_checkout_paypal_pay_button_text', 10, 3 );
function change_checkout_paypal_pay_button_text( $translated_text, $text, $domain ) {
if( 'Proceed to PayPal' === $text ) {
$translated_text = __('Your custom text', $domain); // <== Here the replacement txt
}
return $translated_text;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Now to change the place order text for others payment gateways, you will use in addition the following:
add_filter( 'woocommerce_order_button_text', 'custom_checkout_place_order_text' );
function custom_checkout_place_order_text( $button_text ) {
return __( 'Your custom text here', 'woocommerce' ); // <== custom text Here
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.

How to hide Woocommerce product Description tab only for unlogged users?

How to hide product "Description" tab' in Woocommerce plugin only for unlogged users, but visible for registered customers (and logged-in users).
To remove product description tab on sigle product pages for non logged users, you will use:
add_filter( 'woocommerce_product_tabs', 'customize_product_tabs', 100 );
function customize_product_tabs( $tabs ) {
if ( ! is_user_logged_in() ) {
unset( $tabs['description'] ); // remove the description tab
}
return $tabs;
}
This code goes in functions.php file of your active child theme (or active theme). Tested and works.
Try this, add this snippet into the function.php
add_action( 'init', 'hide_price_add_cart_not_logged_in' );
function hide_price_add_cart_not_logged_in() {
if ( !is_user_logged_in() ) {
//Remove short description (excerpt) from single product page
remove_action( 'woocommerce_product_tabs', 'woocommerce_template_single_excerpt', 20 );
}
}

Disable add to cart button on Woocommerce product category archive pages

How can I disable the "add to basket" button for products only on the "categories" page?
I still want it visible on the product page.
Many thanks
The following will disable add to cart button on product category archive pages:
// Disable add to cart on product category archive pages
add_filter( 'woocommerce_is_purchasable', 'disable_purchasable_on_product_category_archives', 10, 2 );
function disable_purchasable_on_product_category_archives( $purchasable, $product ) {
if( is_product_category() )
$purchasable = false;
return $purchasable;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
To target specific product archive pages you will replace use this instead:
add_filter( 'woocommerce_is_purchasable', 'disable_purchasable_on_product_category_archives', 10, 2 );
function disable_purchasable_on_product_category_archives( $purchasable, $product ) {
// HERE define your product category terms
$terms = array( 'shirts', 'games' );
if( is_product_category( $terms ) )
$purchasable = false;
return $purchasable;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
See: Woocommerce Conditional Tags

Rename Description tab in Woocommerce single product page

I pasted this code in function.php, but it didn't rename the product page tab as it supposed to (http://www.noushasasart.com/product/harsh-bark/)
function woo_remove_product_tabs($tabs) {
unset($tabs['reviews']); // Remove the reviews tab
$tabs['description']['title'] = __('Additional Information'); // Rename the
description tab
return $tabs;
}
how can I solve this?
You have forgotten the filter hook:
add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {
unset($tabs['reviews']); // Remove the reviews tab
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
return $tabs;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested on Woocommerce 3+ and works.
Update (related to your comment) | Rename product description heading (inside the tab):
To rename description heading use woocommerce_product_description_heading filter hook this way:
add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );
function rename_product_description_heading( $heading ) {
return __( 'Additional Information', 'woocommerce' );
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested on Woocommerce 3+ and works.
Official related documentation: Editing product data tabs

Add a custom action button in WooCommerce admin order list

I have followed this instructions to add a custom order status for my WooCommerce Orders.
I can't find a way to create a custom action button that changes the order status to my custom status from the admin order list page like this screenshot:
I would like this custom action button to be shown for the orders that have a "Processing" status.
I could not find any answer in WooCommerce documentation.
Is there a hook to apply these buttons?
How can I add it in the function.php?
Thank you
To resume, you have created a custom order status 'wc-parcial' (with the instructions code provided in your question) and you need to add a related action button to orders admin list.
For WooCommerce version 3.3+ check the update in this answer below
You need to use a custom function hooked in woocommerce_admin_order_actions filter hook
// Add your custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
// Display the button for all orders that have a 'processing' status
if ( $order->has_status( array( 'processing' ) ) ) {
// Get Order ID (compatibility all WC versions)
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
// Set the action button
$actions['parcial'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=parcial&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
'name' => __( 'Envio parcial', 'woocommerce' ),
'action' => "view parcial", // keep "view" class for a clean button CSS
);
}
return $actions;
}
// Set Here the WooCommerce icon for your action button
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
echo '<style>.view.parcial::after { font-family: woocommerce; content: "\e005" !important; }</style>';
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and works. You will get that:
Updated version for Woocommerce 3.3+
To resume, you have created a custom order status 'wc-parcial' (with the instructions code provided in your question) and you need to add a related action button to orders admin list.
The new code:
// Add your custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
// Display the button for all orders that have a 'processing' status
if ( $order->has_status( array( 'processing' ) ) ) {
// The key slug defined for your action button
$action_slug = 'parcial';
// Set the action button
$actions[$action_slug] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=parcial&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'Envio parcial', 'woocommerce' ),
'action' => $action_slug,
);
}
return $actions;
}
// Set Here the WooCommerce icon for your action button
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
$action_slug = "parcial"; // The key slug defined for your action button
echo '<style>.wc-action-button-'.$action_slug.'::after { font-family: woocommerce !important; content: "\e029" !important; }</style>';
}
Code goes in functions.php file of your active child theme (or active theme).
Tested and works

Categories