cliffordp
11/11/2016 - 5:11 PM

WooCommerce: change “Product” to “Ticket” only in the WooCommerce cart and checkout * Useful if only using WooCommerce for Event Tickets Pl

WooCommerce: change “Product” to “Ticket” only in the WooCommerce cart and checkout * Useful if only using WooCommerce for Event Tickets Plus, not selling other Products * * Screenshots: Cart: https://cl.ly/0G2g261z3W1O, Checkout: https://cl.ly/110X201o3M1M

<?php

/**
  * WooCommerce: change “Product” text to “Ticket” only in the WooCommerce cart and checkout
  * Useful if only using WooCommerce for Event Tickets Plus, not selling other Products
  * 
  * Screenshots: Cart: https://cl.ly/0G2g261z3W1O, Checkout: https://cl.ly/110X201o3M1M
  *
  * From https://gist.github.com/cliffordp/431fe3a6d784079c9fe15bb8b205acc0
  *
  * By Zach for https://theeventscalendar.com/support/forums/topic/changing-a-bit-of-text/
  *
  * @link https://docs.woocommerce.com/document/conditional-tags/
  */
function cliff_woo_cart_heading_custom_product_text( $translation, $text, $domain ) {
    if ( 'woocommerce' == $domain && 'Product' == $translation ) {
	    
	    if ( function_exists( 'is_cart' ) && is_cart() ) {
	        return 'Ticket';
	    }
	    
	    if ( function_exists( 'is_checkout' ) && is_checkout() ) {
	        return 'Ticket';
	    }
    }

    return $translation;
}
add_filter( 'gettext', 'cliff_woo_cart_heading_custom_product_text', 20, 3 );