Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

Plugin Development: Storing and Manipulating Data That Fits JSON in Database

$
0
0

I am new to WordPress plugin development but not web development in general. I have a website whose functionality I am trying to port over to WordPress for a client that needs it in a custom plugin and theme.

On my other (non-Wordpress) website, which is a shop page, I have no way of editing the shop items as a client, it is all hard coded into a complex JSON with nested arrays and objects that doesn’t fit well into a MySQL.

An excerpt (it is from an Angular controller):

$scope.theBreadsList = [{
        category: 'Daily Breads',
        breads: [{
            text: 'Apple Streusel',
            category: 'Daily Breads',
            type: 'Apple Streusel',
            instance: 0,
            isDaily: true,
            price: 7.25,
            quantity: 0,
            days: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday"],
            daysNotAvailable: null,
            onMenu: true,
            canSlice: false,
            orderDates: [],
            theActualOrderDate: "",
            shipping: false,
            ingredients: ["White Flour", "Honey", "Water", "Butter", "Brown Sugar", "Eggs", "Applesauce", "Apples", "White Sugar", "Yeast", "Spices", "Vanilla", "Salt"]
        },


        {
            text: 'Honey Whole Wheat',
            category: 'Daily Breads',
            type: 'Honey Whole Wheat',
            instance: 0,
            isDaily: true,
            price: 5.65,
            quantity: 0,
            days: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday"],
            daysNotAvailable: null,
            onMenu: true,
            canSlice: true,
            orderDates: [],
            theActualOrderDate: "",
            shipping: false,
            ingredients: ["Organic Whole Wheat Flour","Filtered Water","Honey","Yeast","Salt"],
        },

Basically for the WordPress plugin, I want the client to be able to enter in such categories and breads (or any other type of item) with all this associated data, to then be added to this format to be read by my Angular script.

Because I can’t conceive of how to do this without storing it as JSON in the database itself (because it is too complex) I am stuck as to how I would have the client edit the data structure from within the plugin.

Sorry this is so vague, but I am hoping someone can help me conceptually with what to do here.


Viewing all articles
Browse latest Browse all 148

Trending Articles