WordPress.org

Forums

Access variables from custom post types for calculations (2 posts)

  1. jcc5018
    Member
    Posted 10 months ago #

    So I need some help. I don't expect someone to make this whole thing for me, but I figured I would explain it so you know what I am trying to do. I am somewhat familar with basic php and how to access data with SQL (though i may need a little refresher) but I'm not sure how to do it with the wordpress codex.

    My main question is: Once I create my custom post types and custom fields that display in those post, with either a plugin or hand coded, how do I access the variables that are created between the custom fields based on taxonomies selected? These variables will be used in calculations that vary per user, and product type

    Below are the custom post types I need to create, and below that is an example of how the data should be used. If you can help at all, that would be appreciated as usual.

    I need to create the following custom post types:

    1. Multipliers- Defines the product multiplier needed to calculate final price.
    Requires (Title, Multiplier Type (Area, Price, Commission, Image, Flat, Commission +Image), Full Price, Middle price (special discounts), Low Price (friends and family), Collection taxonomy selector, and Product Description (if applicable))

    -Sortable by Collection in back end Table based on Collection Taxonomy (already defined)
    -Only the Product description and taxonomy selected will be displayed to front end users
    2. Products- Defines the Individual product description and price
    Requires:
    Title, Detailed item description, SKU, Collection selector from taxonomy, Multiplier type: (Auto determined based on collection selected. Can be over written with Drop down selector.)
    Vendor Selector
    Length field or Height field OR Area field [if length and height is imputed, area is calculated, otherwise inputs into AREA field are used.]
    COGS Field.

    Price will be calculated based on Multiplier Type based on following formulas. Each price will be calculated three times (one for each price level)

    If $type= $area, $price1 = $area * $Multiplier1
    $price2= $area* $Multiplier2
    $price3=$area *$Multiplier3

    If $type=Price, $price1=$COGS*Multiplier1
    If $type=Commission, $price1=$COGS+ Multiplier1
    If $type=Image, $price1= $imgCT * Multiplier1
    If $type=Flat, $price1= $Multiplier1

    If $type= ImageCom, $price1= $COGS +$Multiplier1a +$imgCT*$Multiplier1b

    I need to know how to access the variables in the multiplier field based on the value selected in the collection taxonomy. Each multiplier and product can be assigned to one collection. While each collection will have multiple multipliers, and products.

    3. Vendors: Mainly used to keep track of the venders I use for my products. When an customer places an order, I would like to know which vender supplies the product so I can manually fulfill the order.

    Required Field
    Name, Address, Phone, Email, Website, Notes
    4. Clients
    Required Fields:
    Name, Address, Phone, Email, other contact info, Username, password.
    In addition, each client may be assigned a different multiplier assignment for each product collection.

    So for each top level collection taxonomy, (a total of 9 collections) a client will be assigned to price tier 1, 2 or 3, which their prices will be based on. Default would be tier 1 (normal price)

    Notes:

    Clients field will also be used for shopping cart, and affiliate link program which I will figure out later. A table that keeps track of orders and referral data will be created later.

    Woocommerce could probably handle a lot of these requirements, but i need to modify it a bit to have the multiplier table and only the product information I need. I could probably use its customer information post types and its shopping carts.

    Example: Product = 8x10 print, belongs to glossy print collection, which is a sub of Standard Prints, which is a sub of the "Looking Good collection." All glossy prints are calculated based on an AREA calculation with a $0.80 multiplier at the normal level, $0.50 for a medium level, and $0.25 for a low level. So final price will be calculated and displayed as High= $64, Medium =$40, Low =$20. These prices will all be listed in the back end. But on the front end, only the price corresponding to the client pricing level will be displayed.

    When a user is browsing through the front end products, they will first go through the collections. Each collection has several products such as acrylic prints, canvas prints, or photo albums. These product descriptions will be inputted through the multiplier description box. Each product will have several variants (different sizes), which are inputted through the product post type. Most individual variants will not have its own descriptions, but some will.

    Ideally, when a user browses through the photos, they will select images they like. From there, they will assign a product or more to each photo. Products that require multiple photos (such as photo albums) will be expected to have more photos assigned to them.

  2. Bart Dabek
    Member
    Posted 10 months ago #

    To access any metadata for any custom post type you need to use get post meta function -> http://codex.wordpress.org/Function_Reference/get_post_meta . You just pass in the ID of the post type and field you want to get back.

Reply

You must log in to post.

About this Topic