Welcome to the support center for

Fancy Product Designer & Multistep Product Configurator

Answered

Text element pricing (removable && length == 0)

Hey. First of all I would like to say thanks very much for this awesome plugin.

Its possible to remove element with Trash button. But other users just delete text in edit mode with keyboard Backspace.
We charge 1$ if user edits default text. BUT if user deletes text with Backspace (leaves empty text field) user is charged extra. It's not fair.

1. I suggest to think and implement this logic (only for string elements):
IF element is removable AND text length == 0 THEN do not charge extra.

2. I have managed to add this logic to JS code in if(element.chargeAfterEditing) file FancyProductDesigner.js line ~5900: 

 But how to add same IF in my own JS file? I have hooked into Trigger elementModify but can't get instance (see attached picture).

if (element.removable && text.length == 0 && element._isPriced){
  instance.changePrice(element.price, '-');
  element._isPriced = false;
}

Answer

With the next update for the Pricing Rule add-on 1.0.9, the whitespace will be ignored for price per text length. Then you can apply a rule with a price of 0 when text length is empty and apply further rules when the text contains some text. 

  I have managed to modify price in my own JS file, without changing plugin core files and I don't use pricing add-on.

$(window).load(function () {       
 fancyProductDesigner.$container.on('elementModify', function(evt, element, parameters) {
            console.log('elementModify')

            //don't charge if Text element is empty (Plugin dev planing to implement this modification)
            if(typeof parameters.text === 'string' && element.chargeAfterEditing) {

                let text = parameters.text.trim();

                if (element.removable && text.length == 0 && element._isPriced){
                    let instance = fancyProductDesigner.currentViewInstance;
                    instance.changePrice(element.price, '-');
                    element._isPriced = false;
                }

            }

        });
  });

  

It is already implemented in the available update of the plugin. 


Login or Signup to post a comment