Checkout: item price change when setting zip code

dariodario Member
Hello
I have a weird issue on the checkout (https://mycs.io): what happens is that the price of the item in the cart is updated (wrongly) when the user fills country/zip information. I think what FC does is reduce the price by the amount of VAT but this is wrong; besides the final price of the cart does not change so the information shown is wrong. I'm trying to handle some js events to set the right value back to the UI but I can't make it. What's the reason behind this price change anyway? Can this be avoided somehow?
Thanks
Dario
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @dario,

    As best I can think, the item price shouldn't be changing based on a location changing.

    Could you give us an example address we can try please to replicate?
  • In the checkout page, do only the following steps:
    - open https://mycs.io/#/tisch/1/eckige-beine
    - once the table is displayed, click on "In der warenkorb" button to add it to the cart
    - then click on "warenkorb" on top right corner you will see the cart with prices and vat
    - click Zur Kassew to go to FC checkout
    - at this point the prices will be correct
    - enter 12345 as zip code (don't click the button 'laufen')
    - type "a" in the city field and exit the field
    The item price will change
    Of course the values for zip and city aren't valid but I don't see why this should change the item price decreasing it by the tax amount.
    Thanks
  • fc_adamfc_adam FoxyCart Team
    @dario,

    Looking at your checkout there - I can replicate what you're describing. The reason it's happening though is due to your custom javascript code and the rerendering of the page. Your updates are applying on page load to customise the product prices to add in the VAT - but when that area is rerendered, it's being updated to display the price as it is set for the product in the JSON - which is the price without VAT.

    Rather than doing that in javascript, it might be better to do it within the Twig template - that way it will always be updated whenever the Twig updates. If you'd like a hand with getting that started, we can help you with that.
  • @fc_adam

    I changed the cart include template in order to show not the price of the item but one of its option which we pass when we add items into the cart. So I have something like this in the twig template:

    ...
    {% for item in items %}

    {% set itemPrice = 0 %}
    {% for option in item.options %}
    {% if option.name=='TotalPriceInclTaxes' %}
    {% set itemPrice = option.value %} <----- here I fetch the item price (tax included)
    {% endif %}
    {% endfor %}
    ...

    <div class="fc-cart__item__total">
    {% if item.parent_code == '' or (item.parent_code != '' and item.price > 0) %}
    <p>
    {{ itemPrice|money_format }} <------ here I show the previosuly found result
    </p>
    {% endif %}
    </div>
    ...

    The price is shown correctly at the first time but again, when you go through all the steps (insert city+zip) the price is changed to 0...any idea?

    Thanks
  • fc_adamfc_adam FoxyCart Team
    @dario,

    So the code you've got there is correct - but I think you're running into an issue between the Twig.js implementation and the PHP Twig library. While Twig.js is very close, there are some edge cases that we've picked up on and provide a fix to the maintainers of that library. You're seeing it work on page load through the PHP Twig rendering - but any onpage rendering happens through Twig.js - which is where I believe the issue lies.

    I've created a ticket on our side to look into this and see what might be causing it to occur - and we'll be back in touch as soon as possible.
  • dariodario Member
    edited January 2015
    thanks @fc_adam

    I solved the issue by showing in the template the price multiplied by the VAT, something like:

    {% if item.parent_code == '' or (item.parent_code != '' and item.price > 0) %}
    <p>
    {{ (item.price * 1.19 ) |money_format }}{% if item.price_is_fractional %}<span title="{{ item.price * 1.19 }}">…</span>{% endif %}
    </p>
    {% endif %}
    It's not the best way to do it maybe but at least it works now.
    Thanks
    Dario
  • fc_adamfc_adam FoxyCart Team
    @dario,

    Ah yes - that's a great workaround for now. I'll let you know when we sort out the scoping issue - and you can change back to using a product option if you prefer that approach.
  • lukeluke FoxyCart Team
    Sorry for the delay in getting back to you, but we did resolve these scoping issues in the Twig.js library.
Sign In or Register to comment.