Results 1 to 10 of 1684

Hybrid View

  1. #1
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Dynamic Price Updater

    Quote Originally Posted by preluvbags View Post
    Hi Chrome,

    A big thank you for this marvellous plugin! I've installed it on zc ver 1.5.5f and it is working as designed for.

    I need some help for my custom script. I've added plus and minus buttons to the product quantity and uses jquery to update the quantity input. My custom script is still working but I couldn't get it to update the price. Could you help me please?

    HTML Code:
    Code:
    <div id="cartAdd">
       <h2 id="productPrices" class="productGeneral">S$8.00</h2>
       <span id="button-minus" class="addqty-minus">-</span>
       <input id="addqty" class="addqtycart" type="text" name="cart_quantity" value="1" maxlength="6" size="4">
       <span id="button-plus" class="addqty-plus">+</span>
       <input type="hidden" name="products_id" value="1">
       <input class="cssButton submit_button button button_in_cart" onmouseover="this.className='cssButtonHover button_in_cart button_in_cartHover'" onmouseout="this.className='cssButton submit_button button  button_in_cart'" type="submit" value="Add to Cart">
    </div>
    Javascript:
    Code:
    $(document).ready(function() {
       var chkqty = $('#addqty').val();
       $("#button-minus").click(function(){
          var addqty	= $('#addqty').val();
          if(parseInt(addqty)>1) {
             var newval	= parseInt(addqty) - 1;
             $('#addqty').val(newval);
             return true;
          }else{
             return false;
          }
       });
       $('#button-plus').click(function(){
          var addqty	= $('#addqty').val();
          var newval	= parseInt(addqty) + 1;
          $('#addqty').val(newval);
          return true;
       });
     });
    Hope you or someone could help me, thank you guys!
    The javascript code that has been added to modify some number related to the overall product quantity, does not force the actions to occur for the updated entry. In the above code, the val is updated, but javascript does not take action on that programattic change. It would take action if the user had specifically modified the field directly. I have also not forced a change of the val to cause such an update, leaving someone that writes such additional code to incorporate the necessary action.

    See below (untested) what I think would fix this issue for your site:
    Code:
    $(document).ready(function() {
       var chkqty = $('#addqty').val();
       $("#button-minus").click(function(){
          var addqty	= $('#addqty').val();
          if(parseInt(addqty)>1) {
             var newval	= parseInt(addqty) - 1;
             $('#addqty').val(newval);
             $('#addqty').change();
             return true;
          }else{
             return false;
          }
       });
       $('#button-plus').click(function(){
          var addqty	= $('#addqty').val();
          var newval	= parseInt(addqty) + 1;
          $('#addqty').val(newval);
          $('#addqty').change();
          return true;
       });
     });
    I added a manual call to the change event for the field being edited by the addition of:
    Code:
    $('#addqty').change();
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #2
    Join Date
    Jul 2018
    Location
    Singapore
    Posts
    5
    Plugin Contributions
    0

    Default Re: Dynamic Price Updater

    Hi mc12345678,

    Thank you so much for your super fast response. I tried adding $('#addqty').change() but no luck; it still couldn't update.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Dynamic Price Updater

    Quote Originally Posted by preluvbags View Post
    Hi mc12345678,

    Thank you so much for your super fast response. I tried adding $('#addqty').change() but no luck; it still couldn't update.
    Have a link to an effected page?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jul 2018
    Location
    Singapore
    Posts
    5
    Plugin Contributions
    0

    Default Re: Dynamic Price Updater

    Quote Originally Posted by mc12345678 View Post
    Have a link to an effected page?
    Apology, it's internal server at the moment so I don't have an external link for you to access. Is there any other way I could get around this?

  5. #5
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Dynamic Price Updater

    Quote Originally Posted by preluvbags View Post
    Apology, it's internal server at the moment so I don't have an external link for you to access. Is there any other way I could get around this?
    Well, I was wondering if there were javascript errors that were causing it not to function properly. Does DPU still function properly if the user manually updates the quantity field while your script is installed? Also is what has been provided for code all that is added to support the additional functionality?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jul 2018
    Location
    Singapore
    Posts
    5
    Plugin Contributions
    0

    Default Re: Dynamic Price Updater

    Quote Originally Posted by mc12345678 View Post
    Well, I was wondering if there were javascript errors that were causing it not to function properly. Does DPU still function properly if the user manually updates the quantity field while your script is installed? Also is what has been provided for code all that is added to support the additional functionality?
    Yes, that's correct. DPU is working as intended and there isn't any js error; no other js has been added till yet.

  7. #7
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Dynamic Price Updater

    Quote Originally Posted by preluvbags View Post
    Yes, that's correct. DPU is working as intended and there isn't any js error; no other js has been added till yet.
    Ok, so went and reproduced the code/situation. While there may still be a better way to implement this, what I did that worked was to instead modify the javascript code like so:
    Code:
    $(document).ready(function() {
        var chkqty = $('#addqty').val();
        $("#button-minus").click(function(){
           var addqty    = $('#addqty').val();
           if(parseInt(addqty)>1) {
              var newval    = parseInt(addqty) - 1;
              $('#addqty').val(newval);
              try {
                 init();
              } catch (call_err) {
                 console.log(call_err.stack);
              }
             return true;
           }else{
              return false;
           }
        });
        $('#button-plus').click(function(){
           var addqty    = $('#addqty').val();
           var newval    = parseInt(addqty) + 1;
           $('#addqty').val(newval);
           try {
              init();
           } catch (call_err) {
              console.log(call_err.stack);
           }
          return true;
        });
      });

    This worked for me and would update after every increase/decrease made by clicking the + or -.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 Help with dynamic price updater
    By anderson6230 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 23 Jul 2014, 08:52 AM
  2. v139h Dynamic Price Updater 3.0 Help!
    By Newbie 2011 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 12 Mar 2014, 06:46 AM
  3. Dynamic Price Updater Error
    By Inxie in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 26 Oct 2012, 06:19 PM
  4. Alternative to Dynamic Price Updater?
    By thebigkick in forum General Questions
    Replies: 0
    Last Post: 9 Jul 2012, 11:41 PM
  5. Dynamic Price Updater with href
    By maxell6230 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 1 Mar 2012, 12:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg