Reply To: Customize the "Add to cart" button on the page of a product with WooCommerce
I would like to edit the php, specifically functions.php to be able to edit the button it says add to the cart. In other themes I have been able to change it from html or from function.php, but this does not work for me. Where should I edit if I want to change the text that says “add to cart”? Any advice or help is welcome. regards
changes that I would like to add to functions.php or the site in general are as follows:
add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
function custom_override_checkout_fields( $fields ) {
$fields[‘order’][‘order_comments’][‘placeholder’] = ‘Plazo requerido y dirección’;
$fields[‘order’][‘order_comments’][‘label’] = ‘Informe el plazo requerido de arriendo y la dirección donde se utilizarán los Containers’;
return $fields;
}
add_action( ‘woocommerce_after_order_notes’, ‘my_custom_checkout_field’ );
function my_custom_checkout_field( $checkout ) {
echo ‘<div id=”my_custom_checkout_field”>’;
woocommerce_form_field( ‘my_field_name’, array(
‘type’ => ‘text’,
‘class’ => array(‘my-field-class form-row-wide’),
‘label’ => __(‘Rut’),
‘placeholder’ => __(‘Ingrese su rut’),
), $checkout->get_value( ‘my_field_name’ ));
echo ‘</div>’;
}
add_filter( ‘gettext’, ‘ld_custom_checkout_button_text’, 20, 3 );
function ld_custom_checkout_button_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case ‘Finalizar compra’ :
$translated_text = __( ‘Enviar cotización’, ‘woocommerce’ );
break;
}
return $translated_text;
}
add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woo_custom_cart_button_text’ );
function woo_custom_cart_button_text() {
global $woocommerce;
foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values[‘data’];
if( get_the_ID() == $_product->id ) {
return __(‘Solicitar Cotización’, ‘woocommerce’);
}
}
return __(‘Solicitar Cotización’, ‘woocommerce’);
}