Hi,

I would like to modify the content of the messages displayed when adding/removing/updating the contents of the cart.
In uc_ajax_cart.module I found $settings which contains the text string for the messages displayed, among other values:

$settings = array(
'CALLBACK' => url(UC_AJAX_CART_ADD_CALLBACK),
'SHOW_CALLBACK' => url(UC_AJAX_CART_SHOW_CALLBACK) ,
'ADD_MESSAGE' => t('Add product to cart'),
'ADD_TITLE' => t('Please wait'),
'REMOVE_MESSAGE' => t('Remove product from cart'),
'REMOVE_TITLE' => t('Please wait'),
'CART_LINK_CALLBACK' => url(UC_AJAX_CART_LINK_CALLBACK),
'BLOCK_UI' => (int) variable_get('ajax_cart_message_effect' , UC_AJAX_CART_DEFAULT_EFFECT ) ,
'TIMEOUT' => (int) variable_get('ajax_cart_message_timeout', UC_AJAX_CART_DEFAULT_TIMEOUT ) ,
'UPDATE_CALLBACK' => url(UC_AJAX_CART_UPDATE_CALLBACK) ,
'UPDATE_MESSAGE' => t('Update cart') ,
'SESSION' => session_id(),
'ON_CLICK' => variable_get('uc_ajax_cart_closed',0),
'UPDATE' => variable_get('uc_ajax_cart_closed_update',0),
'CART_OPERATION' => t('Cart'),
'CART_VIEW_ON' => variable_get('uc_ajax_cart_cart_view', 0),
'SHOW_VIEW_CALLBACK' => url(UC_AJAX_CART_SHOW_VIEW_CALLBACK)
);

Which is the best practice for modifying the text strings of my interest without hacking the module?
Thanks.

Comments

tunic’s picture

Status: Active » Closed (won't fix)

The best practice is to override strings in the JS layer. Write a JS code that overwrites Drupal.settings.uc_ajax_cart variables.

But take into account that messages displayed come from various places. Check this table:

Action Operation msg Result msg
Msg title when update in cart page ADD_TITLE CART_OPERATION
Msg when update in cart page UPDATE_MESSAGE CART_OPERATION
Add to cart msg title ADD_TITLE CART_OPERATION
Add to cart message ADD_MESSAGE Hardcoded in uc_cart module
Msg title when updating using add to cart button ADD_TITLE CART_OPERATION
Msg when updating using add to cart button ADD_MESSAGE Hardcoded in uc_cart module
Msg title when removing product REMOVE_TITLE CART_OPERATION
Msg when removing product ADD_MESSAGE Hardcoded in uc_ajax_cart module

For example, to modify message title from operation info display you have to override Drupal.settings.uc_ajax_cart.ADD_TITLE.

As you can see not all strings are controlled by UC AJAX cart. So, for now, this strings are not going to be configurable.

Bartezz’s picture

Hi,

Old issue but accidentally bounced into this. For others who are looking for a solution to this; I always use string overrides module whenever I have a lot of strings to alter. Works well with uc_ajax_cart as well!

Cheers