How to calculate the cart price based on variable field drop-down selection in catalog item?

Santhosh15
Tera Guru

Hello Experts,

 

I have one requirement based on choices, i need to calculate the cart price with below quantity.

  1.  Choices are Yan
    • 40mm x 15mm $19.45 per Yan
    • 70mm x 25mm $21.95 per Yan
  2. single select field called No. of Yans required with drop down options
    • 1
    • 2
    • 3
    • 4
    • 5

I have script but it is not working and tried with ui policy by creating the two fields "No. of Yans". We are hiding and showing quantity field based on selection of choices of Yan. We hardcoded the prices for two fields "No. of Yans".

But i think, this was not the better approach to do this implementation.

 

This is the on change client script and it is working only on catalog item view. 
This code is not working from portal side.

 

if (isLoading || newValue =='') {
g_form.clearValue('no_of_yan');
g_form.removeOption('no_of_yan', '70mm1');
g_form.removeOption('no_of_yan', '70mm2');
g_form.removeOption('no_of_yan', '70mm3');
g_form.removeOption('no_of_yan', '70mm4');
g_form.removeOption('no_of_yan', '70mm5');
g_form.removeOption('no_of_yan', '40mm1');
g_form.removeOption('no_of_yan', '40mm2');
g_form.removeOption('no_of_yan', '40mm3');
g_form.removeOption('no_of_yan', '40mm4');
g_form.removeOption('no_of_yan', '40mm5');
}

else if (newValue == 'ls_40x15') {
g_form.addInfoMessage("40mm");

g_form.addOption('no_of_yan', '40mm1', '1');
g_form.addOption('no_of_yan', '40mm2', '2');
g_form.addOption('no_of_yan', '40mm3', '3');
g_form.addOption('no_of_yan', '40mm4', '4');
g_form.addOption('no_of_yan', '40mm5', '5');

g_form.removeOption('no_of_yan', '70mm1');
g_form.removeOption('no_of_yan', '70mm2');
g_form.removeOption('no_of_yan', '70mm3');
g_form.removeOption('no_of_yan', '70mm4');
g_form.removeOption('no_of_yan', '70mm5');
}
else{
g_form.addInfoMessage("70mm");

g_form.addOption('no_of_yan', '70mm1', '1');
g_form.addOption('no_of_yan', '70mm2', '2');
g_form.addOption('no_of_yan', '70mm3', '3');
g_form.addOption('no_of_yan', '70mm4', '4');
g_form.addOption('no_of_yan', '70mm5', '5');

}

 

Can anyone suggest to do with catalog client script?

 

@Ankur Bawiskar @Chuck Tomasi @Ravi Chandra_K @Mark Roethof 

 

Thanks in Advance

0 REPLIES 0