/** * Check to see if the order includes a product that requires an account and if there is an account in the system * * Return values: * 1 = The account exists * 0 = There is no account associated with the order and there is no need for one * -1 = There is no account associated with the order but there should be * * @return int */ public function hasAccount() { if ($this->id == 0 || empty($this->id)) { throw new Cart66Exception(66400, 'Cannot get account status on an order with no order id'); } Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Account ID on order: " . $this->account_id); if ($this->account_id > 0) { return 1; // The order has an account associated with it } else { // No account exists for this order, but does it need one? $product = new Cart66Product(); $items = $this->getItems(); foreach ($items as $item) { $product->load($item->product_id); if ($product->isMembershipProduct() || $product->isSubscription()) { return -1; // No account exists but there should be one } } } return 0; // No account exists and none is needed. }
public function accountCreate($attrs) { $render_form = false; if (isset($attrs['product'])) { $product = new Cart66Product(); $product->load($attrs['product']); if ($product->id <= 0) { $product->loadByItemNumber($attrs['product']); } if ($product->isMembershipProduct() || $product->isPayPalSubscription()) { $render_form = true; } } $data = array('attrs' => $attrs, 'render_form' => $render_form); $view = Cart66Common::getView('pro/views/account-create.php', $data); return $view; }
public function isMembershipProduct() { $product = new Cart66Product($this->_productId); return $product->isMembershipProduct(); }