I don't have 50 reputation on stack overflow, so I can't comment on post. To ask a question I gotta make a new question unfortunately :/
So, from here :
Changing WooCommerce cart item names
OP asked about changing WooCommerce cart item names.
The answer below, which
@https://stackoverflow.com/users/3730754/loictheaztec
reply helped me but it isn't complete enough..
I've tested the code he gave,
add_filter( 'woocommerce_before_calculate_totals', 'custom_cart_items_prices', 10, 1 );
function custom_cart_items_prices( $cart_object ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
// Iterating through cart items
foreach ( $cart_object->get_cart() as $cart_item ) {
// Get the product name (item name)
$id = $cart_item['data']->get_name();
// THE NEW NAME
$new_name = 'mydesiredproductname';
// Set your cart item name
$cart_item['data']->set_name( $new_name );
}
}
it works great, for the code above on the cart page, checkout page customer invoice page and admin order page is changed to "mydesiredproductname" but I want the Cart Page, the Checkout Page, the customer invoice page and the admin order page to remain the same, only thing is changed is the item name that is submitted to payment gateway. Wonder if that is possible? Or what is the closest that I can achieve?
ps: I tested is_cart
and also is_checkout
function, for is_cart the cart is unchanged, for is_checkout the checkout page is unchanged.
Any help would be greatly appreciated Thanks !