Announcement

Collapse
No announcement yet.

Cart popup widget corrupts other info input.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cart popup widget corrupts other info input.

    Tested on Swift 18.0.6 site with the Cart Popup widget installed.

    Give a product an Other Info prompt. E.g. Other Info.

    Add product to cart with "Test £25 ¬ ¦" as the other info input.

    Display cart and Other Info now contains "Test £25 ¬ ¦".

    It looks like all characters with the high bit set are being prefixed with an extraneous "Â".
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    #2
    The problem seem to be in this fragment of code in sdwidget.min.js that is used to send the product form data to the cart via AJAX:
    Code:
    data:i.serialize()
    This calls the jQuery serialize function and it uses JavaScript's encodeURIComponent to do the actual work. This routine assumes utf-8 encoding where the £ sign is represented by 2 consecutive hex characters C2 A3.

    However SellerDeck pages are using iso-8859-1 encoding and this uses a single character encoding scheme. E.g. hex A3 for £.

    When encodeURIComponent does it's work it expands single character £ into %C2%A3, passes it to the Shopping Cart via AJAX and our utf-8 pages subsequently display that as £.

    The solution is to replace jQuery .serialize() with an iso-8859-1 compatible one. I found such a fix on the jQuery Forum https://forum.jquery.com/topic/non-utf-8-serialization

    Edit sdwidget.min.js and add the following at the beginning:
    Code:
    // based on jQuery Forum - https://forum.jquery.com/topic/non-utf-8-serialization
    $.fn.serializeISO8859 = function(){
    	var s = []; 
    	$.each( this.serializeArray(), function( i, v ){s.push(v.name.replace(/\+/g, '%2B') + "=" + v.value.replace(/\+/g, '%2B'));});
    	return s.join("&").replace(/%20/g, '+');
    }
    And look for the fragment of code:
    Code:
    .serialize()
    and replace with:
    Code:
    .serializeISO8859()
    For completeness do the same to file sdwidget.js.
    Last edited by NormanRouxel; 27-Feb-2021, 04:27 PM. Reason: Updated to make new code more concise
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman, that's extremely helpful as always. I've raised a bug for this, ref. SDE-748
      Bruce Townsend
      Ecommerce Product Manager
      Sellerdeck Ecommerce Solutions

      Comment

      Working...
      X