Skip to content

Instantly share code, notes, and snippets.

@tribulant
Created October 30, 2014 13:43
Show Gist options
  • Save tribulant/664f2f1eec9bf8140c45 to your computer and use it in GitHub Desktop.
Save tribulant/664f2f1eec9bf8140c45 to your computer and use it in GitHub Desktop.
Order Items and Variations
<?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