Forum

Thread tagged as: Problem, Shop

Additional order information fields not showing up in admin

Hi got an issue.

In addition to usual address, email address etc. I have set up some additional fields in the section where the customer enters their billing address, shipping address etc.

Namely two text areas for 'special instructions on safe places for delivery' And a 'Gift Message' - When entered by a customer I can't get them to appear in the order detail page in the admin panel.

I've entered them in the 'customer_create.html' template...

<div>
            <perch:label for="shipping_instructions">Delivery Instructions</perch:label>
            <perch:input type="textarea" id="shipping_instructions" label="Delivery Instructions" class="field"/>
        </div>

        <div>
            <perch:label for="shipping_gift">Gift Message</perch:label>
            <perch:input type="textarea" id="shipping_gift" label="Gift Message" class="field"/>
        </div>

Any idea how I can get these to show up in the order detail so the client can action them?

Nik Gill

Nik Gill 1 points

  • 3 years ago

Nik

Likely your going to have to add similar fields to the Customer admin forms or Order admin for these fields to show up in admin. See the function your using and make sure the fields you added are also part of the form that function is using. You may have to turn on debug to see which template this is.

Duncan Revell

Duncan Revell 78 points
Registered Developer

I have a feeling that the order page/view is fixed - as in it won't know to pick up any additional fields you've, um, added.

Got to be a way of doing though, right... I mean it's basic functionality? standard template doesn't include a phone number field... and I need to add one of those in too

Nik, have you tried my solution? I am not at a computer where I can try, but this would take less then a minute to verify...

Sorry, yeah Robert... I have enabled debug but its not shown me anything that I would consider useful. Sorry, I forgot to reply to you directly on that

However I have just this found the the php file which controls that page 'order.detail.post.php'

I could potentially add what I need into this page... but my limited php knowledge means I don't know what I have to do to convert the value the form collects to what this page can understand.

Ideally I'd like to put this information in the 'Additional Information' at the bottom of the page and I have identified the area it can go in...

echo '<tr>';
                echo '<th>Shipping Instructions</th>';
                echo '<td>'<!-- SHIPPING INSTRUCTIONS HERE-->'</td>';
            echo '</tr>';

Don't really want to muck about with this too much, but I have succeeded in creating this table row and printing the email address into it

Don't know how to convert the 'shipping_instructions' field id I'm collecting on the form to a value this page can understand and show for me though :(

I don’t see why this info if added during the checkout process wouldn’t be available in the order.html template at admin time.

I just downloaded the perch_shop files on my phone so I have limited view right now, but if the fields are added to template used for taking the order, then it should be available viewing the order in admin if also added to this template.

When in front of computer if there is no solution posted I will test and reply.

R. K

That was my thinking... but looking at the order.detail.post.php which seems to control that view, there doesn't seem be be any allowances for 'rogue' fields... unless I've given them the wrong id or they need prefixing in some way to pick up.

Hoping Drew might have a view on this when/if he sees this

Robert Ketter said:

When in front of computer if there is no solution posted I will test and reply.

R. K

Thanks Robert, that would be much appreciated... I'm really 'Through the looking glass' on this one

Robert... I've managed to add it in ok by editing the order.detail.post.php file... maybe I shouldn't have done it, but it works and I can now see the values of those fields in the order detail on the admin.

For reference I added in the following to show these

echo '<tr>';
                echo '<th>Shipping Instructions</th>';
                echo '<td>'.$HTML->encode($ShippingAdr->instructions()).' </td>';
            echo '</tr>'; 
            echo '<tr>';
                echo '<th>Gift Message</th>';
                echo '<td>'.$HTML->encode($ShippingAdr->shipping_gift()).' </td>';
            echo '</tr>';

Well. Technically that’s modifying the app, so I am not going to praise you for it...lol

Just so it’s clear, this was not my suggestion and modifications to perch apps is explicitly prohibited and will void support for your app until you update it to a non modified status.

That being said, I am glad you found a solution that works, but it may cost you in the end :(

R. K

Don't worry Robert, I don't intend for it to stay that way at all... I don't feel good about doing it BUT my client needs this information today so she can send her orders out. I'll put it back as it should be as soon as she's got what she needs out!

I'm going to continue to dig around and try and find a legitimate way of collecting the data that I need... whatever happens I'm going to need a way of collecting the telephone number on registration too.

There HAS to be a 'proper' way of collecting and displaying additional data for an order... surely?

Duncan Revell

Duncan Revell 78 points
Registered Developer

Nik,

you could maybe try the export functionality in the Shop/Orders app - see if that gives you all your data. Otherwise a "hidden" page you create that shows all the order details you need to see (or maybe use the headless/API feature if using Runway).

Granted, it's not handily displayed in the admin, but there are ways to get the info out.

I'd love to say I understood that Duncan... I really would... but I don't unfortunately

I'm using standard Perch, not runway currently for this as I've been using it for years... but this is the first Shop app implementation I've gone through (which for the most part has gone much better than I expected)

Ah, actually I do know what you mean Duncan... yes, exporting the order addresses via the export to csv file shows that data that I'm missing in the admin

Duncan Revell

Duncan Revell 78 points
Registered Developer

No worries - we can ignore the Runway bit anyway!

If you check out the Shop documentation, there are page functions that relate to orders - so you could create a page and template that would show any of the order information you want. In theory, you could make the template output order information as a csv file, or a plain old table, or... whatever really. You could then hide that page away (behind a member login) and then your client could browse to that page to see whatever data you want them to see.

It won't be nicely available in the admin section, but you could provide a way to get to the custom data...

Thanks Duncan... I think the fact the data can be viewed by exporting the order as a csv file might possibly be enough for the client if the data can't be added into the admin panel. I don't think that's any harder for them to do that your suggestion so that'll probably be ok if thats the only other way besides showing it in the order detail.

Such a shame if it turns out that additional data can't be viewed in the order detail... I was under the impression it would be a similar system to perch:content... i.e if I add in a field to my template it appears in the admin for that page. Though I realise the Shop app needs to be more rigid. Be useful if a future feature could be the addition of an additional field area that picks up any additional fields related to the order and pulls them in instead of being locked down... but hey, I'm probably being silly thinking that!

WOW, Stop the presses....

What do you think this part of order.detail.post is.... Like exactly what you're looking for.... $Order->orderDynamicFields()

I am looking into it right now so I would just hang in there...

Ooooh, never noticed that Robert... but to be fair I don't really know what I'm looking for that deep into the CMS

So, All you have to do is on your checkout page you need to call perch_shop_form() with a template as option, in this template you can gather any additional fields you want like where to leave package, phone number to call or ... then this information will be passed as key=>value to the "Additional Information" section on the bottom of the Order page in the admin.

So everything you want is already part of Perch_Shop.... you just gotta be patient... lol

Remember, I was part of the very extensive Perch_Shop beta developers so I really am pretty informed about this... lol

RK