public static function productsPage() { $data = array(); $subscriptions = array('0' => 'None'); if (class_exists('SpreedlySubscription')) { $spreedlySubscriptions = SpreedlySubscription::getSubscriptions(); foreach ($spreedlySubscriptions as $s) { $subs[(int) $s->id] = (string) $s->name; } if (count($subs)) { asort($subs); foreach ($subs as $id => $name) { $subscriptions[$id] = $name; } } } else { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not loading Spreedly data because Spreedly class has not been loaded"); } $data['subscriptions'] = $subscriptions; $view = Cart66Common::getView('admin/products.php', $data); echo $view; }
public function drawFeatureLevelMetaBox($post) { if (CART66_PRO) { $plans = array(); $featureLevels = array(); $data = array(); // Load feature levels defined in Spreedly if available if (class_exists('SpreedlySubscription')) { $sub = new SpreedlySubscription(); $subs = $sub->getSubscriptions(); foreach ($subs as $s) { // $plans[] = array('feature_level' => (string)$s->featureLevel, 'name' => (string)$s->name); $plans[(string) $s->name] = (string) $s->featureLevel; $featureLevels[] = (string) $s->featureLevel; } } // Load feature levels defined in PayPal subscriptions $sub = new Cart66PayPalSubscription(); $subs = $sub->getSubscriptionPlans(); foreach ($subs as $s) { $plans[$s->name] = $s->featureLevel; $featureLevels[] = $s->featureLevel; } // Load feature levels defined in Membership products foreach (Cart66Product::getMembershipProducts() as $membership) { $plans[$membership->name] = $membership->featureLevel; $featureLevels[] = $membership->featureLevel; } // Put unique feature levels in alphabetical order if (count($featureLevels)) { $featureLevels = array_unique($featureLevels); sort($featureLevels); $savedPlanCsv = get_post_meta($post->ID, '_cart66_subscription', true); $savedFeatureLevels = empty($savedPlanCsv) ? array() : explode(',', $savedPlanCsv); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Saved Plans: {$savedPlanCsv} -- " . print_r($savedFeatureLevels, true)); $data = array('featureLevels' => $featureLevels, 'plans' => $plans, 'saved_feature_levels' => $savedFeatureLevels); } $box = Cart66Common::getView('pro/views/feature-level-meta-box.php', $data); echo $box; } }