Set different label for "Order Now" button on each catalog items

Rintaro Ueno
Tera Contributor

Hi All,

 

I have a requirement to set different label for "Order Now" button on the catalog item page (on the Next Experience UI, not on Portal).

To fulfill this requirement, I copied the existing Macro "sc_order_item_buttons" and edited it in the following way.

 

1. Create custom checkbox "Change button label" to Catalog Item[sc_cat_item] table.

RintaroUeno_0-1697509648585.png

 

2. Edit copied macro to evaluate if "Change Button Label" field of current catalog item is true.

 

 

<g:evaluate var="jvar_change_button_label" jelly="true">
	var jvar_change_button_label = false;
  var itemID = jelly.RP.getParameterValue("sysparm_id");
	var item_GR = new GlideRecord('sc_cat_item');
	item_GR.addQuery('u_change_button_label', true);
	item_GR.query();
	while(item_GR.next()){
		if(itemID == item_GR.sys_id){
			jvar_change_button_label = true;
			break;
		}
	}
</g:evaluate>

 

 

 

3. Configured IF statement for a part of the jelly that seems to control "Order Now" button label.

    Plus, added another IF tag to change the label when "Change Button Label" for current catalog item is true.

 

 

<j:if test="${sysparm_cart_edit == null}">
	<j:if test="${jvar_oi_order_now_button_override == 'true'} &amp;&amp; ${jvar_change_button_label=='false'}">
		<g:sc_button classes="request_catalog_button_with_icon"
			img="images/button_cursor.gifx"
			id="oi_order_now_button"
			onclick="processOrderNow(false)"
			label="${jvar_sc_order_now_label}"
			title="${jvar_sc_order_now_label}"
			isPrimary="true"/>
	</j:if>
	<j:if test="${jvar_oi_order_now_button_override == 'true'} &amp;&amp; ${jvar_change_button_label=='true'}">
		<g:sc_button classes="request_catalog_button_with_icon"
			img="images/button_cursor.gifx"
			id="oi_order_now_button"
			onclick="processOrderNow(true)"
			label="xxx"  //<= Custom label for "Order Now" button									
			title="${jvar_sc_order_now_label}"
			isPrimary="true"/>
	</j:if>

 

 

 

After the configuration above, I replaced the existing macro with the customized macro on "Order this Item" cart layout.

RintaroUeno_1-1697510198507.png

 

As a result, "Order Now" button is no longer displayed regardless of True/False value for "Change Button Label" column on each catalog items.

RintaroUeno_2-1697510331415.png


Can anyone tell me what is wrong with this implementation?
And how can I improve it?

 

I would appreciate your help.

2 REPLIES 2

Hi @Kalyani Jangam1 
Thank you for your reply.

I have already checked those articles, but they do not resolve the problem,

because,  as I understand it, when I configure "Order now" button label on Cart Layout widget or on Message[sys_ui_message] record, then it affects all catalog items.

However, what I'd like to do is to display different button label on each catalog items.

For example, on Catalog Item A, the label shows "Order Now", whereas on Catalog Item B, it shows "Send Request" and so on.

Do you have any idea to fulfill this requirement?

Thank you.