• hello –

    i am thinking the best way to pass a custom value using jQuery might be something like this:

    jQuery("input.asp_product_custom_field_input").val("Marks Custom Value");  
    jQuery(".asp_product_custome_field_input").prop("readonly", true); 
    jQuery("input#asp-custom-field-0").prop("disabled", true); 

    any opinions?

    EDIT:

    this works too:

    jQuery("input[name=charge_description]").val('New Value!');

    • This topic was modified 6 years, 3 months ago by edwardsmark.
    • This topic was modified 6 years, 3 months ago by edwardsmark.
    • This topic was modified 6 years, 3 months ago by edwardsmark.
    • This topic was modified 6 years, 3 months ago by edwardsmark.
    • This topic was modified 6 years, 3 months ago by edwardsmark.
    • This topic was modified 6 years, 3 months ago by edwardsmark.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter edwardsmark

    (@edwardsmark)

    this code seems to work fine:

    jQuery( document ).ready( () =>  {
    
      jQuery('div.asp_product_item_top').hide();   // hide the product description
      jQuery('div.asp_product_description').hide();   // hide the product description
      jQuery('label.asp_product_custom_field_label').hide();   // hide the product custom field label
        
      const defaultDescription = jQuery('input[name=charge_description]').val() ;  //establish default
         
      jQuery('input.asp_product_custom_field_input').prop('readonly', true);
    
      jQuery("[name='dropdown-content']").on('change', (eventData, handler) => {
    
          let selectedLanguage = jQuery("[name='dropdown-content'] option:selected").text();
    
          jQuery('input.asp_product_custom_field_input').val(selectedLanguage);
            
          let newTitle
                = selectedLanguage
            	  +	' -- '
            	  +	defaultDescription
            	  ;
    
          jQuery('input[name=charge_description]').val(newTitle); 
          stripehandler0.data.description = newTitle;
      });
    });

    i am using “dropdown content” to create a drop down menu, and using “ad inserter” to include the jQuery stuff.
    any other suggestions or thoughts?

    • This reply was modified 6 years, 3 months ago by edwardsmark.
    • This reply was modified 6 years, 3 months ago by edwardsmark.
    Plugin Contributor Alexander C.

    (@alexanderfoxc)

    Hi.

    As I understand, you want the custom value to be changed depending of the dropdown select value?

    You can try to use product variations for your needs, for example: https://s-plugins.com/creating-variable-products-using-the-stripe-payments-plugin/

    It would create a dropdown for you without any need to use any additional javascript.

    If you can provide an example of what you’re trying to achieve exactly, I can think of some other suggestions ??

    Thread Starter edwardsmark

    (@edwardsmark)

    i am trying to use a drop-down to pass a custom value. your variable-products option looks very useful, but i cannot seem to cause the plugin to either change the title in the stripe payment popup nor pass values into stripe itself. in my case, the price is not changing.

    in other words, our customers will (hopefully) make a $99 purchase. they must choose which language they wish to purchase, and they are all the same price. the customers’ selected language will be passed to stripe via your ultra-cool custom-field option.

    the short description obviously then just appears on invoices, emails, etc.

    stripe passes both of these values back during the “callback” – this is extraordinarily useful.

    my jQuery code is modifying the custom-code value:

    let selectedLanguage = jQuery("[name='dropdown-content'] option:selected").text();
    jQuery('input.asp_product_custom_field_input').val(selectedLanguage);

    the rest of the code is changing the short description:

    let newTitle     = selectedLanguage
            	  +	' -- '
            	  +	defaultDescription
            	  ;
    
    jQuery('input[name=charge_description]').val(newTitle); 
    stripehandler0.data.description = newTitle;
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘passing jQuery custom value’ is closed to new replies.