The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

adding a custom field to the purchase order section

I have modified the purchase order field so that staff can use it to process check or cash payments. The PO number is being used as a passcode field...which only staff know. This works! A regular visitor can't submit the cart if they don't know the code. But I would like to add an additional custom field to the PO section that only shows when the PO option is selected and this field would contain the Check number. I know you can add custom fields, but how do you add the custom field to the Purchase Order section? And equally important, what is the way to access this custom PO field data from the XML datafeed? (if it is the same as other custom fields, no problem).
  • fc_adamfc_adam FoxyCart Team
    edited March 2018

    Good question. To add a field inside the purchase order section, your best bet currently would be to add that with javascript. You could do that like this:
    {% if context == "checkout" %}
    FC.client.on("render.done", function() {
    if ($(".custom-check-number").length == 0 && FC.json.payment_method_type == "purchase_order") {
    var check = (FC.json.hasOwnProperty("check_number")) ? FC.json.check_number : "";
    $("#fc-payment-method-purchase-order .fc-input-group-container--active").append('<div class="fc-form-group custom-check-number"><label class="fc-container__grid--label--po fc-form-label" for="check_number">Check #</label><div class="fc-container__grid--input--po"><input type="text" id="check_number" name="check_number" value="' + check + '" maxlength="100" placeholder="" autocomplete="off" data-fc-required="" class="fc-form-control fc-form-control--po"></div></div>');
    {% endif %}
    You would include that code in your store's custom footer. You set that from the "configuration" section of your store's FoxyCart administration, enable the "Add custom header and footer code to your templates" option if it's not already and paste the code into the footer textarea.

    That should add in a second "Check #" field right below the existing PO field to capture the additional data. That extra field will be treated just like a normal custom checkout field though - so you'll see it on the receipt in the additional information section, and will be accessible from the custom_fields node in the datafeed too.
  • Awesome...Thank you....Thank you....
Sign In or Register to comment.