Forum
productDynamicFields, Dashboard
I'm using Perch Shop in Runway to sell training courses. I've added some extra fields into the product template including date, venue, duration of each course. When I add products, these fields are stored in the productDynamicFields column of the perch2_shop_products table.
I've also built a simple Dashboard app to present data on orders. I'm using get_rows to run a query on the database and present the results on the Dashboard - and that's all working well.
But I'd like the Dashboard app to be able to access the extra product fields as well - eg to show the orders for courses by date or by venue. My get_rows query is giving me an array with a row for each product. I can include productDynamicFields in my database query, and it gives pairs of names/values like this:
{"duration":"3","date":"2017-01-10","venue":"North Hotel, Anytown","description": ... ... etc etc ... ... }
How would I show just one of my extra fields eg "date" without showing everything else in productDynamicFields? Can anyone point me in the right direction?
Summary information
Perch Runway: 2.8.32, PHP: 7.0.13, MySQL: 10.0.27-MariaDB, with PDO
Server OS: Linux, litespeed
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_events (1.9.3), perch_forms (1.8.3), perch_gallery (2.8.6), interact_orders (1), perch_shop_orders (1.0.10), perch_shop_products (1.0.10), my_sample (2.1), perch_shop (1.0.10), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_gallery', 'perch_forms', 'perch_events', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /cms
PERCH_PATH: /home/northernfirstaid/public_html/cms
PERCH_CORE: /home/northernfirstaid/public_html/cms/core
PERCH_RESFILEPATH: /home/northernfirstaid/public_html/cms/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 1024M, Total max file upload: 100M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: northern.test-singlepage.co.uk
DOCUMENT_ROOT: /home/northernfirstaid/public_html
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
You probably don't want to query the database directly. Use the API instead.
Fantastic - thanks.
Sorry but I think I need to query the database, because I want to pull in order, product and customer details from different tables. My Dashboard app is basically as follows:
This presents all the productDynamicFields in one column of the finished table. Is there any way I can present columns in my finished table for my specific extra fields like date, venue and duration? Perhaps by amending the database query or by manipulating the $result1 array? I've been playing around with json decode to no effect - along these lines:
I'm getting this in debug: Undefined index: DYNAMIC FIELDS