Ecommerce Shopify WordPress Discussion

Adding a Dynamic Product Name to the Woocommerce Cart

on the shop page I appended the product text with custom text using the following hook: add_action('woocommerce_shop_loop_item_title','customize_shop_page_product_title'); The user chooses a family name in a search and then the shop page adds the name to the product title. Their choice is stored in a cookie. So my product title on the shop page would change from say "Baseball Cap" to say "Baseball Cap Smith". When the user clicks the add to cart button I would like that the full appended text be added to the Cart. So "Baseball Cap Smith" would be added to the cart not "Baseball Cap". The difficult part is that the custom text may change to another name if the user changes the name, say from Smith to Acheson. Then the product name would be "Baseball Cap Acheson". So in the cart there could be "Baseball Cap Acheson" and "Baseball Cap Smith". However the original name of the product is Baseball Cap. The name that is appended is set in a cookie, changable by the user. How can i get the dynamic product name to the cart ? function customize_shop_page_product_title() { if(isset($_COOKIE['family'])){ $attachment_title = get_the_title($_COOKIE['family']); $custom_text = '<strong>'.$attachment_title.'</strong>'; echo '<h3 class="woocommerce-loop-product__title">' . get_the_title() .$custom_text.'</h3>'; } } add_action('woocommerce_shop_loop_item_title','customize_shop_page_product_title');
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.