P
P
Pavel Pavel2018-07-28 00:45:55
WordPress
Pavel Pavel, 2018-07-28 00:45:55

How to change "Continue Shopping" button to "Checkout" using php for WooCommerce?

Hello.
I have code:

$titles = array_filter( $titles );
  /* translators: %s: product name */
  $added_text = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', $count, 'woocommerce' ), wc_format_list_of_items( $titles ) );

  // Output success messages.
  if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
    $return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) );
    $message   = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'woocommerce' ), esc_html( $added_text ) );
  } else {
    $message = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( wc_get_page_permalink( 'cart' ) ), esc_html__( 'View cart', 'woocommerce' ), esc_html( $added_text ) );
  }

With it, the user, when adding a product to the cart, sees the message: "You have added product "123" to your cart", and next to it there is a button "Continue Shopping".
What changes need to be made to the php code so that instead of the "Continue Shopping" button there is a "Checkout" button with a transition to the order page? Selling will be one product without the ability to buy multiple copies. That is, for one account - one product.
PS: First of all, I changed the name of 'Continue shopping' to 'Continue shopping' and instead provided a direct link to the checkout page. However, it didn't help. As a result, I got the following. Where the message "You have added product “123" to your cart" was indicated, now it says "<a href="%s" class="button wc-forward">%s</a>Continue shopping" the full link of the order page has been registered.
I will be glad for your ideas and help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Loginov, 2020-08-29
@Maxim_1317

I don’t know why you need php, but there is a plugin for translations and editing inscriptions. It's called Loco translate. If there is already a translation into Russian, click edit and change the inscriptions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question