147 lines
4.0 KiB
PHP
147 lines
4.0 KiB
PHP
<?php
|
|
|
|
add_filter('gettext', 'bbloomer_translate_woocommerce_strings', 999, 3);
|
|
|
|
function bbloomer_translate_woocommerce_strings($translated, $text, $domain)
|
|
{
|
|
if (!is_admin() && 'woocommerce' === $domain) {
|
|
|
|
switch (strtolower($translated)) {
|
|
|
|
case 'view cart':
|
|
$translated = 'View Cart';
|
|
break;
|
|
|
|
case 'proceed to checkout':
|
|
$translated = 'Checkout Resources';
|
|
break;
|
|
|
|
case 'checkout':
|
|
$translated = 'Checkout Resources';
|
|
break;
|
|
|
|
case 'add to cart':
|
|
$translated = 'Add to Cart';
|
|
break;
|
|
|
|
case 'place order':
|
|
$translated = 'Complete Checkout';
|
|
break;
|
|
|
|
case 'your order':
|
|
$translated = 'Your Order';
|
|
break;
|
|
|
|
case 'product':
|
|
$translated = 'Product';
|
|
break;
|
|
|
|
case 'products':
|
|
$translated = 'Products';
|
|
break;
|
|
|
|
case 'cart totals':
|
|
$translated = 'Cart Totals';
|
|
break;
|
|
|
|
case 'browse products':
|
|
$translated = 'Browse Products';
|
|
break;
|
|
|
|
case 'orders':
|
|
$translated = 'Orders';
|
|
break;
|
|
|
|
case 'return to shop':
|
|
$translated = 'Find More Products';
|
|
break;
|
|
|
|
// enter a new case for each line where you want Woocommerce text to be changed.
|
|
}
|
|
}
|
|
return $translated;
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
// Continue Shopping Button Redirect
|
|
add_filter('woocommerce_continue_shopping_redirect', function () {
|
|
return get_home_url() . '/shop';
|
|
});
|
|
|
|
function woo_add_continue_shopping_button_to_single()
|
|
{
|
|
$shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
|
|
|
|
echo '<div class="woocommerce-message">';
|
|
echo ' <a href="' . $shop_page_url . '" class="button wc-forward">Continue Shopping</a>Looking for more items to add?';
|
|
echo '</div>';
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Add Continue Shopping Button on Cart Page
|
|
* Add to theme functions.php file or Code Snippets plugin
|
|
*/
|
|
add_action('woocommerce_before_cart', 'woo_add_continue_shopping_button_to_cart');
|
|
|
|
function woo_add_continue_shopping_button_to_cart()
|
|
{
|
|
$shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
|
|
|
|
echo '<div class="woocommerce-message">';
|
|
echo ' <a href="' . $shop_page_url . '" class="button wc-forward">Find More Resources</a>Looking for more items to add?';
|
|
echo '</div>';
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
Remove Unwanted Woocommerce Fields
|
|
**/
|
|
function wc_remove_checkout_fields($fields)
|
|
{
|
|
|
|
// Billing fields
|
|
unset($fields['billing']['billing_company']);
|
|
// unset($fields['billing']['billing_email']);
|
|
unset($fields['billing']['billing_phone']);
|
|
unset($fields['billing']['billing_state']);
|
|
unset($fields['billing']['billing_first_name']);
|
|
unset($fields['billing']['billing_last_name']);
|
|
unset($fields['billing']['billing_address_1']);
|
|
unset($fields['billing']['billing_address_2']);
|
|
unset($fields['billing']['billing_city']);
|
|
// unset($fields['billing']['billing_postcode']);
|
|
|
|
// Shipping fields
|
|
unset($fields['shipping']['shipping_company']);
|
|
unset($fields['shipping']['shipping_phone']);
|
|
// unset($fields['shipping']['shipping_state']);
|
|
// unset($fields['shipping']['shipping_first_name']);
|
|
// unset($fields['shipping']['shipping_last_name']);
|
|
// unset($fields['shipping']['shipping_address_1']);
|
|
unset($fields['shipping']['shipping_address_2']);
|
|
// unset($fields['shipping']['shipping_city']);
|
|
// unset($fields['shipping']['shipping_postcode']);
|
|
|
|
// Order fields
|
|
// unset($fields['order']['order_comments']);
|
|
|
|
return $fields;
|
|
}
|
|
// add_filter('woocommerce_checkout_fields', 'wc_remove_checkout_fields');
|
|
|
|
/**
|
|
Reorder Woocommerce Billing Fields
|
|
**/
|
|
|
|
add_filter('woocommerce_checkout_fields', 'quadlayers_email_top');
|
|
|
|
function quadlayers_email_top($checkout_fields)
|
|
{
|
|
$checkout_fields['billing']['billing_email']['priority'] = 5;
|
|
return $checkout_fields;
|
|
}
|