После нажатия кнопки «Добавить в КОРЗИНУ» отображается сообщение «[Товар] был добавлен в вашу корзину... Посмотреть корзину».
Нам нужно добавить к этому сообщению вторую кнопку с надписью «Продолжить покупки» (которая возвращает на страницу МАГАЗИН).
Мы думали, что нашли подходящий php, но он отображает «Продолжить», а не «Продолжить». покупка».
Изменение текста в php (ниже), похоже, не работает, затем мы заметили, что в php (выделено ниже) написано «Просмотреть корзину», но на самом деле отображаемый текст говорит «Просмотреть корзину». В чем мы ошиблись?
PHP ниже НЕ отформатирован как «код», так как я не смог тогда выделить определенные области.
// Add 2nd 'Continue' buttom to woo message, see:
// https://stackoverflow.com/questions/780 ... oocommerce
add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 3 );
function filter_wc_add_to_cart_message_html( $message, $products, $show_qty ) {
$titles = array();
$count = 0;
$product_id = null;
foreach ( $products as $product_id =\> $qty ) {
/* translators: %s: product name */
$titles[] = apply_filters( 'woocommerce_add_to_cart_qty_html', ( $qty > 1 ? absint( $qty ) . ' × ' : '' ), $product_id ) . apply_filters( 'woocommerce_add_to_cart_item_name_in_quotes', sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ), $product_id );
$count += $qty;
}
$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 ) );
$message = esc_html( $added_text );
$btn_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '';
$return_to = wc_get_page_permalink( 'shop' );
$message .= sprintf( ' %s', esc_url( $return_to ), esc_attr( $wp_button_class ), esc_html__( 'Continue', 'woocommerce' ) );
return $message . sprintf( ' %s', esc_url( wc_get_cart_url() ), esc_attr( $wp_button_class ), esc_html__( '**View cart**', 'woocommerce' ) );
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... roduct-has