Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conditional Pricing... in a related table... via PHP?

Featured Replies

In order to have more flexibility over pricing (different pricing for... different clients, different web sites, coupons, etc...), I plan to move pricing to a related table rather than in the same table as products.

Price Codes attached to clients, orders, and invoices would relate down to the correct price.

To view prices in a product list, I'd just set a global to the priceCode and base a relationship on that. but that isn't going to work with PHP since it doesn't support globals in that way (right?).

So what would be my options for implementing this or another flexible pricing model using PHP?

I'm still a little fuzzy on what you're trying to do.

I'm assuming a Table called Products related via ProductID to a table called Pricing. I'm also assuming that price_code will be retrieved elsewhere. Say from a Customer table or a Coupons table and passed (or sessioned) to the Products.php page with your list of products.

Given that; this should work.

Put a portal to pricing in the products layout, and make sure that the price_code field present along with the other information you want to use / display.

Grab all prices for a product from FMP then use PHP to filter out the correct one based on the supplied $price_code variable.

  • Author

nice one. thanks.

I hadn't used or thought to use portals on a php layout before.

  • 2 weeks later...

Ran into the same problem with a customers/contacts setup. I thought about doing as Baloo suggested, but to grab all the contacts for me would have meant 20000 records to get from the DB, then I had to filter them.

I chose to use use AJAX to do the same thing. It was easier than I thought. Using AJAX i only queried the DB for the records that pertained to the customer selected.

Don't know if you get the FileMaker Advisor magazine, but I used Jonathan Starks method( http://my.advisor.com/doc/19445 )

  • 2 weeks later...

Yeah limiting the number of records returned is a requirement for reasonable page load times. AJAX is a great way to go. I've been using it and have gotten some decent millage out of six fried rice's JSON converter

http://sixfriedrice.com/wp/products/filemaker-to-json-converter/

it works for eval but if you want to use PHP's json_decode() function with the result you'll need to replace the single quote field:value delimiters with double quotes

I don't have access to Stark's article so no comment there. If anyone else doesn't and want's to start laying around but googling "ajax" and "json" should get you all the information you need to get started.

If you don't want to use AJAX and you have too may records in your related set you could also perform a second query to the pricing table based on the results from your Products table.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.