Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Tom Steer 161 posts 596 karma points
    Feb 14, 2019 @ 16:55
    Tom Steer

    HTML API isn't respecting the method field value


    I'm trying to update the payment & shipping method using the HTML form API and it doesn't appear to be respecting the value on the SetCurrentPaymentMethod field. The form I'm using is (removed some markup for ease of reading):

    <form action="/base/TC/FormPost.aspx" method="post" class="form-horizontal form-autoValidate" novalidate="novalidate">
        <input name="SetCurrentPaymentMethod" value="paymentShippingMethod.PaymentMethodId" type="hidden">
        <input name="SetCurrentShippingMethod" value="paymentShippingMethod.ShippingMethodId" type="hidden">
        <input name="returnUrl" type="hidden" value="/gb-en/checkout/review/">
        <input name="storeId" value="1" type="hidden">
        <select id="paymentShippingMethod_PaymentMethodId" name="paymentShippingMethod.PaymentMethodId"><option value="1">Invoicing</option></select>
        <select id="paymentShippingMethod_ShippingMethodId" name="paymentShippingMethod.ShippingMethodId"><option value="1">Pickup</option><option value="3">Free Delivery</option></select>

    And the values that get posted are:

    SetCurrentPaymentMethod: paymentShippingMethod.PaymentMethodId
    SetCurrentShippingMethod: paymentShippingMethod.ShippingMethodId
    returnUrl: /gb-en/checkout/review/
    storeId: 1
    paymentShippingMethod.PaymentMethodId: 1
    paymentShippingMethod.ShippingMethodId: 3

    However the order.PaymentInformation.PaymentMethodId & order.ShipmentInformation.ShippingMethodId remain null.

    The reason the field names are different is because I'm used strongly typed form models with the HTML helper @Html.DropDownListFor(x => paymentShippingMethod.PaymentMethodId, paymentMethods.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString()})).

    Thanks, Tom

  • Matt Brailsford 4099 posts 22021 karma points MVP 9x c-trib
    Feb 14, 2019 @ 17:01
    Matt Brailsford

    Hey Tom,

    So I think I can see the issue. So in the docs, it shows to set the Payment/Shipping methods by doing the following:

    <input name="SetCurrentShippingMethod" value="shippingMethodId" type="hidden">
    <input name="shippinMethodId" value="1" type="hidden" />

    Now it is possible to changed what input name is used, but there is a specific syntax for it (which I don't actually think is documented in the documentation, so I'll need to look at adding it).

    Ultimately, the value "shippingMethodId" is an expected string, but if you want to change it you need to do the following:

    <input name="SetCurrentShippingMethod" value="shippingMethodId:paymentShippingMethod.ShippingMethodId" type="hidden">
    <input name="paymentShippingMethod.ShippingMethodId" value="1" type="hidden" />

    So the syntax is shippingMethodId:alternativeFieldName.

    Hopefully this helps, but I'll go add an issue to the docs issure tracker to get this documented.


  • Matt Brailsford 4099 posts 22021 karma points MVP 9x c-trib
    Feb 14, 2019 @ 17:05
    Matt Brailsford

    The issue for this is here incase you want to track it

  • Tom Steer 161 posts 596 karma points
    Feb 14, 2019 @ 17:06
    Tom Steer

    Thanks Matt, that worked perfectly.

  • Matt Brailsford 4099 posts 22021 karma points MVP 9x c-trib
    Feb 14, 2019 @ 17:14
    Matt Brailsford

    Actually it does look to be documented, but maybe not that clear. And I think we can add links to this from other areas.

Please Sign in or register to post replies

Write your reply to: