/**
  * Run function after saving
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         Citruscart::load("CitruscartHelperProduct", 'helpers.product');
         $helper = CitruscartHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($this->product_id, '0');
     }
     return $return;
 }
 /**
  * Run function when saving
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable');
         $pa->load($this->productattribute_id);
         Citruscart::load("CitruscartHelperProduct", 'helpers.product');
         $helper = CitruscartHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($pa->product_id);
     }
     return $return;
 }
示例#3
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         if ($this->_increase_coupon_uses) {
             $coupon = JTable::getInstance('Coupons', 'CitruscartTable');
             $coupon->load(array('coupon_id' => $this->coupon_id));
             $coupon->coupon_uses = $coupon->coupon_uses + 1;
             if (!$coupon->save()) {
                 JFactory::getApplication()->enqueueMessage($coupon->getError());
             }
         }
     }
     return $return;
 }
示例#4
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $prev = clone $this;
     if (!empty($this->id)) {
         $prev->load($this->id);
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($prev->subscription_enabled && empty($this->subscription_enabled)) {
             // if it was previously enabled and now is disabled
             Citruscart::load('CitruscartHelperJuga', 'helpers.juga');
             $helper = new CitruscartHelperJuga();
             $helper->doExpiredSubscription($this);
         }
     }
     return $save;
 }
 /**
  * (non-PHPdoc)
  * @see DSCTable::save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $isNew = false;
     if (empty($this->productcomment_id)) {
         $isNew = true;
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($this->productcomment_enabled && empty($this->rating_updated)) {
             // get the product row
             $product = JTable::getInstance('Products', 'CitruscartTable');
             $product->load($this->product_id);
             $product->updateOverallRating();
             if (!$product->save()) {
                 $this->setError($product->getError());
             } else {
                 $this->rating_updated = '1';
                 parent::store();
             }
         } elseif (!$this->productcomment_enabled && !empty($this->rating_updated)) {
             // comment has been disabled after it already updated the overall rating
             // so remove it from the overall rating
             // get the product row
             $product = JTable::getInstance('Products', 'CitruscartTable');
             $product->load($this->product_id);
             $product->updateOverallRating();
             if (!$product->save()) {
                 $this->setError($product->getError());
             } else {
                 $this->rating_updated = '0';
                 parent::store();
             }
         }
     }
     return $save;
 }
示例#6
0
 public function save($src = '', $orderingFilter = '', $ignore = '')
 {
     // Check the table activation status first
     if (!$this->active) {
         // Activate it with a default value
         $this->setType('');
     }
     return parent::save($src, $orderingFilter, $ignore);
 }
示例#7
0
 /**
  * Saves the order to the db table
  *
  * (non-PHPdoc)
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         // create the order_number when the order is saved, since it is based on the auto-inc value
         $order_number_prefix = Citruscart::getInstance()->get('order_number_prefix');
         if (!empty($order_number_prefix) && empty($this->order_number) && !empty($this->order_id)) {
             $this->order_number = $order_number_prefix . $this->order_id;
             $this->store();
         }
         // If the order_credit > 0.00, then save a usage in the order credits, with a - value of the credit amount
         if ($this->order_credit > '0.00' && $this->_adjustCredits) {
             $credit = JTable::getInstance('Credits', 'CitruscartTable');
             $credit->user_id = $this->user_id;
             $credit->order_id = $this->order_id;
             $credit->credittype_code = 'usage';
             $credit->credit_enabled = '1';
             $credit->credit_amount = 0 - $this->order_credit;
             $credit->save();
         }
         // TODO All of the protected vars information could be saved here instead, no?
     }
     return $return;
 }
示例#8
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $isNew = false;
     if (empty($this->credit_id)) {
         $isNew = true;
     }
     $prev = clone $this;
     $prev->load($this->id);
     $wasWithdrawableBefore = $prev->credit_withdrawable;
     $wasEnabledBefore = $prev->credit_enabled;
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if (($isNew && $this->credit_enabled || !$isNew && $this->credit_enabled) && empty($this->credits_updated)) {
             // add the credits to the total
             $userdata = JTable::getInstance('UserInfo', 'CitruscartTable');
             $userdata->load(array('user_id' => $this->user_id));
             $userdata->user_id = $this->user_id;
             $credit_balance_before = $userdata->credits_total;
             $withdrawable_balance_before = $userdata->credits_withdrawable_total;
             $userdata->credits_total = $userdata->credits_total + $this->credit_amount;
             if ($this->credit_withdrawable) {
                 $userdata->credits_withdrawable_total = $userdata->credits_withdrawable_total + $this->credit_amount;
             }
             if (!$userdata->save()) {
                 $this->setError($userdata->getError());
             } else {
                 $this->credits_updated = '1';
                 $this->credit_balance_before = $credit_balance_before;
                 $this->credit_balance_after = $userdata->credits_total;
                 $this->withdrawable_balance_before = $withdrawable_balance_before;
                 $this->withdrawable_balance_after = $userdata->credits_withdrawable_total;
                 parent::store();
             }
         } elseif (!$isNew && !$this->credit_enabled && !empty($this->credits_updated)) {
             // if this is an existing credit that is now being disabled,
             // remove the credits from the total
             $userdata = JTable::getInstance('UserInfo', 'CitruscartTable');
             $userdata->load(array('user_id' => $this->user_id));
             $userdata->user_id = $this->user_id;
             $userdata->credits_total = $userdata->credits_total - $this->credit_amount;
             if ($this->credit_withdrawable) {
                 $userdata->credits_withdrawable_total = $userdata->credits_withdrawable_total - $this->credit_amount;
             }
             if (!$userdata->save()) {
                 $this->setError($userdata->getError());
             } else {
                 $this->credits_updated = '0';
                 $this->credit_balance_before = 0;
                 $this->credit_balance_after = 0;
                 $this->withdrawable_balance_before = 0;
                 $this->withdrawable_balance_after = 0;
                 parent::store();
             }
         }
         if (!$isNew && $this->credit_enabled && !empty($this->credits_updated) && $this->credit_withdrawable && !$wasWithdrawableBefore) {
             // if this is an existing credit that is enabled
             // and it has already updated the credits_total for the user
             // but is now being changed to a withdrawable amount,
             // then we need to adjust the user's withdrawable total
             $userdata = JTable::getInstance('UserInfo', 'CitruscartTable');
             $userdata->load(array('user_id' => $this->user_id));
             $userdata->user_id = $this->user_id;
             $withdrawable_balance_before = $userdata->credits_withdrawable_total;
             $userdata->credits_withdrawable_total = $userdata->credits_withdrawable_total + $this->credit_amount;
             if ($userdata->save()) {
                 $this->withdrawable_balance_before = $withdrawable_balance_before;
                 $this->withdrawable_balance_after = $userdata->credits_withdrawable_total;
                 parent::store();
             }
         }
         if (!$isNew && !empty($this->credits_updated) && !$this->credit_withdrawable && $wasWithdrawableBefore && $wasEnabledBefore) {
             // if this is an existing credit
             // and it has already updated the credits_total for the user
             // but is now being changed to a non-withdrawable amount,
             // then we need to adjust the user's withdrawable total
             $userdata = JTable::getInstance('UserInfo', 'CitruscartTable');
             $userdata->load(array('user_id' => $this->user_id));
             $userdata->user_id = $this->user_id;
             $withdrawable_balance_before = $userdata->credits_withdrawable_total;
             $userdata->credits_withdrawable_total = $userdata->credits_withdrawable_total - $this->credit_amount;
             if ($userdata->save()) {
                 $this->withdrawable_balance_before = $withdrawable_balance_before;
                 $this->withdrawable_balance_after = $userdata->credits_withdrawable_total;
                 parent::store();
             }
         }
     }
     return $save;
 }