• Michelle

    (@michmyers990)


    Hi!
    We use WordPress headless with JS framework Gatsby and we are currently developing the checkout age. We use the htmlSnippet in the Gui to render checkout on frontend and everything works fine but when we click on “Go to payment” we get this error (language: norwegian)
    Kan ikke bekrefte bestillingen, vennligst fors?k igjen.

    We did some digging and the output of the error says this:
    Cart items are not in sync. Please try again or reload the checkout

    I am not sure why the cart items are not syncing, but I found out that by changing this variable to return false, everything works:

    // Whether or not to do mapping validation
    $should_do_mapping_validation = apply_filters( 'woocommerce_sco_should_do_cart_items_mapping_validation', false);

    So I have two questions: what does this “mapping validation” do and why do we need it?
    Can we somehow set it to false? I tried with a hook but nothing seems to work.

    Thank you,
    Michelle

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author The Generation

    (@thegeneration)

    Hi,

    The error message means that there are items in Svea that’s not present in the visitors cart or vice versa. It’s a safe measure to ensure that all items have been synced properly before processing the payment.

    If you’re sure that you want to disable that feature you should be able to use the following code in you child theme or via plugin:

    add_filter( 'woocommerce_sco_should_do_cart_items_mapping_validation' '__return_false');

    Best regards

    Thread Starter Michelle

    (@michmyers990)

    Hi and thank you for your answer.
    The filter worked but now we are pondering if it isn’t better to actually make the sync work instead of just setting to false.
    We tested the plugin on a classic (so not headless) WordPress and the same error appear, is this something you could help us with?

    https://varmeshop.jkweb.hekko24.pl

    Plugin Author The Generation

    (@thegeneration)

    Hi,

    Unfortunately we can’t see or do much by only seeing the front end of the page, we would need access to the admin dashboard at least. In order to give more detailed support I suggest that you contact us via [email protected] where we can ask for more sensitive information.

    But before doing so I noticed that the site is using “simple” permalinks which could be the issue in this case. Please head to “Settings > Permalinks” and change the structure to “Post name”. To see if that made any difference, also flush all carts via “WooCommerce > Status > Tools > Clear customer sessions” to ensure that the new permalink is being used when you try to checkout out again.

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change $should_do_mapping_validation to false’ is closed to new replies.