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

Posted over 4 years ago by dkvadratu (remove this account)

Post a topic
Answered
d
dkvadratu (remove this account)

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;
}

0 Votes

rady kal

rady kal posted over 4 years ago Admin Best 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. 

0 Votes


3 Comments

Sorted by
rady kal

rady kal posted over 4 years ago Admin

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

0 Votes

Deividas dkvadratu

Deividas dkvadratu posted over 4 years ago

  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;
                }

            }

        });
  });

  

0 Votes

rady kal

rady kal posted over 4 years ago Admin 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. 

0 Votes

Login or Sign up to post a comment