Created
October 30, 2014 13:43
-
-
Save tribulant/664f2f1eec9bf8140c45 to your computer and use it in GitHub Desktop.
Order Items and Variations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $wpcoDb, $Order, $Item, $Style, $Option; | |
$wpcoDb -> model = $Item -> model; | |
if ($items = $wpcoDb -> find_all(array('order_id' => $order -> id))) { | |
$variations = maybe_unserialize($item -> styles); | |
foreach ($variations as $variation_id => $option_id) { | |
$wpcoDb -> model = $Style -> model; | |
// Here you get the variation | |
$variation = $wpcoDb -> find(array('id' => $variation_id)); | |
// Is the variation maybe checkboxes, causing multiple options? | |
if (is_array($option_id)) { | |
$option_ids = $option_id; | |
foreach ($option_ids as $option_id) { | |
$wpcoDb -> model = $Option -> model; | |
$option = $wpcoDb -> find(array('id' => $option_id)); | |
} | |
// Variation is select or radio so just one option | |
} else { | |
$wpcoDb -> model = $Option -> model; | |
$option = $wpcoDb -> find(array('id' => $option_id)); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment