◆ __construct()
ilPaymentShoppingCart::__construct |
( |
|
$user_obj | ) |
|
◆ __deleteDoubleEntries()
ilPaymentShoppingCart::__deleteDoubleEntries |
( |
| ) |
|
|
private |
Definition at line 310 of file class.ilPaymentShoppingCart.php.
References $ilUser, $res, and $row.
Referenced by __construct().
313 if(ANONYMOUS_USER_ID != $ilUser->getId())
315 $res = $this->db->queryf(
' 316 SELECT pobject_id, count(pobject_id) count FROM payment_shopping_cart 317 WHERE customer_id = %s 318 GROUP BY pobject_id',
319 array(
'integer'), array($this->user_obj->getId()));
321 while(
$row = $this->db->fetchAssoc(
$res))
323 if(
$row[
'count'] > 1)
325 $this->db->setLimit(1);
326 $this->db->manipulateF(
' 327 DELETE FROM payment_shopping_cart 328 WHERE customer_id = %s 329 AND pobject_id = %s',
330 array(
'integer',
'integer'),
331 array($this->user_obj->getId(),
$row[
'pobject_id']));
◆ __read()
ilPaymentShoppingCart::__read |
( |
| ) |
|
|
private |
Definition at line 338 of file class.ilPaymentShoppingCart.php.
References $_SESSION, $ilUser, $res, $row, ilPaymentPrices\_getTotalAmount(), ilPaymentPrices\_priceExists(), getSessionId(), setPobjectId(), and setTotalAmount().
Referenced by __construct(), add(), delete(), emptyShoppingCart(), and update().
341 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
343 $this->sc_entries = array();
346 &&
$_SESSION[
'shop_user_id'] != ANONYMOUS_USER_ID
347 || $this->user_obj->getId() != ANONYMOUS_USER_ID)
349 $res = $this->db->queryf(
' 350 SELECT * FROM payment_shopping_cart 351 WHERE customer_id = %s',
352 array(
'integer'), array($this->user_obj->getId()));
354 else if(ANONYMOUS_USER_ID == $ilUser->getId())
356 $res = $this->db->queryf(
' 357 SELECT * FROM payment_shopping_cart 358 WHERE session_id = %s',
362 while(
$row = $this->db->fetchObject(
$res))
364 $this->sc_entries[
$row->psc_id][
"psc_id"] =
$row->psc_id;
365 $this->sc_entries[
$row->psc_id][
"customer_id"] =
$row->customer_id;
366 $this->sc_entries[
$row->psc_id][
"pobject_id"] =
$row->pobject_id;
367 $this->sc_entries[
$row->psc_id][
"price_id"] =
$row->price_id;
368 $this->sc_entries[
$row->psc_id][
'session_id'] =
$row->session_id;
374 foreach($this->sc_entries as $entry)
379 $this->
delete($entry[
'psc_id']);
384 $tmp_pobj =
new ilPaymentObject($this->user_obj, $entry[
'pobject_id']);
386 $pay_method = $tmp_pobj->getPayMethod();
387 if($pay_method == $tmp_pobj->PAY_METHOD_NOT_SPECIFIED)
389 $this->
delete($entry[
'psc_id']);
394 if($tmp_pobj->getStatus() == $tmp_pobj->STATUS_EXPIRES)
396 $this->
delete($entry[
'psc_id']);
402 $this->sc_entries[$entry[
'psc_id']][
'pay_method'] = $pay_method;
405 'id' => $entry[
'price_id'],
406 'pay_method' => $pay_method
static _priceExists($a_price_id, $a_pobject_id)
static _getTotalAmount($a_price_ids)
◆ _assignObjectsToUserId()
static ilPaymentShoppingCart::_assignObjectsToUserId |
( |
|
$a_user_id | ) |
|
|
static |
◆ _deleteExpiredSessionsPSC()
static ilPaymentShoppingCart::_deleteExpiredSessionsPSC |
( |
| ) |
|
|
static |
Definition at line 573 of file class.ilPaymentShoppingCart.php.
References $ilDB, and $query.
577 $query =
"DELETE FROM payment_shopping_cart " 579 .
" (SELECT psc_id FROM payment_shopping_cart " 580 .
" LEFT JOIN usr_session ON usr_session.session_id = payment_shopping_cart.session_id " 581 .
" WHERE customer_id = %s AND usr_session.session_id IS NULL)";
582 $ilDB->manipulateF(
$query, array(
'integer'), array(ANONYMOUS_USER_ID));
◆ _deleteShoppingCartEntries()
static ilPaymentShoppingCart::_deleteShoppingCartEntries |
( |
|
$a_pobject_id | ) |
|
|
static |
◆ _hasEntries()
static ilPaymentShoppingCart::_hasEntries |
( |
|
$a_user_id | ) |
|
|
static |
Definition at line 286 of file class.ilPaymentShoppingCart.php.
References $ilDB, $ilUser, and $res.
290 if(ANONYMOUS_USER_ID == $ilUser->getId())
292 $res = $ilDB->queryf(
' 293 SELECT * FROM payment_shopping_cart 294 WHERE session_id = %s',
295 array(
'text'), array(self::getSessionId()));
299 $res = $ilDB->queryf(
' 300 SELECT * FROM payment_shopping_cart 301 WHERE customer_id = %s',
302 array(
'integer'), array($a_user_id));
305 return $ilDB->numRows(
$res) ? true :
false;
◆ _migrateShoppingcart()
static ilPaymentShoppingCart::_migrateShoppingcart |
( |
|
$a_old_sessid, |
|
|
|
$a_new_sessid |
|
) |
| |
|
static |
Definition at line 118 of file class.ilPaymentShoppingCart.php.
References $ilDB.
122 $ilDB->update(
'payment_shopping_cart',
123 array(
'session_id' => array(
'text', $a_new_sessid)),
124 array(
'session_id'=> array(
'text', $a_old_sessid)));
◆ add()
ilPaymentShoppingCart::add |
( |
| ) |
|
Definition at line 184 of file class.ilPaymentShoppingCart.php.
References $ilUser, __read(), getPobjectId(), getPriceId(), and getSessionId().
188 if(ANONYMOUS_USER_ID == $ilUser->getId())
191 $statement = $this->db->manipulateF(
' 192 DELETE FROM payment_shopping_cart 193 WHERE session_id = %s 194 AND pobject_id = %s',
195 array(
'integer',
'integer'),
202 $statement = $this->db->manipulateF(
' 203 DELETE FROM payment_shopping_cart 204 WHERE customer_id = %s 205 AND pobject_id = %s',
206 array(
'integer',
'integer'),
207 array($this->user_obj->getId(), $this->
getPobjectId()));
210 $next_id = $this->db->nextId(
'payment_shopping_cart');
212 $this->db->insert(
'payment_shopping_cart',
213 array(
'psc_id' => array(
'integer', $next_id),
214 'customer_id'=> array(
'integer', $this->user_obj->getId()),
215 'pobject_id' => array(
'integer', $this->
getPobjectId()),
216 'price_id' => array(
'integer', $this->
getPriceId()),
◆ calcDiscountPrices()
ilPaymentShoppingCart::calcDiscountPrices |
( |
|
$coupons | ) |
|
Definition at line 538 of file class.ilPaymentShoppingCart.php.
540 if (is_array($coupons))
544 foreach ($coupons as $coupon)
546 $this->coupon_obj->setId($coupon[
'pc_pk']);
547 $this->coupon_obj->setCurrentCoupon($coupon);
549 if (is_array($coupon[
'items']) && $coupon[
'total_objects_coupon_price'] > 0)
551 $bonus = ($this->coupon_obj->getCouponBonus($coupon[
'total_objects_coupon_price']));
553 foreach ($coupon[
'items'] as $item)
555 if (!array_key_exists($item[
'pobject_id'], $r_items))
557 $r_items[$item[
'pobject_id']] = $item;
558 $r_items[$item[
'pobject_id']][
'discount_price'] = (float) $item[
'math_price'];
561 $ratio = (float) $item[
'math_price'] / $coupon[
'total_objects_coupon_price'];
562 $r_items[$item[
'pobject_id']][
'discount_price'] += ($ratio * $bonus * (-1));
◆ clearCouponItemsSession()
ilPaymentShoppingCart::clearCouponItemsSession |
( |
| ) |
|
Definition at line 520 of file class.ilPaymentShoppingCart.php.
References $_SESSION.
524 foreach (
$_SESSION[
'coupons'] as $payment_type => $coupons_array)
526 if (is_array($coupons_array))
528 foreach ($coupons_array as $coupon_key => $coupon)
530 $_SESSION[
'coupons'][$payment_type][$coupon_key][
'total_objects_coupon_price'] = 0.0;
531 $_SESSION[
'coupons'][$payment_type][$coupon_key][
'items'] = array();
◆ delete()
ilPaymentShoppingCart::delete |
( |
|
$a_psc_id | ) |
|
◆ emptyShoppingCart()
ilPaymentShoppingCart::emptyShoppingCart |
( |
| ) |
|
Definition at line 261 of file class.ilPaymentShoppingCart.php.
References $ilUser, __read(), and getSessionId().
264 if(ANONYMOUS_USER_ID == $ilUser->getId())
266 $statement = $this->db->manipulateF(
' 267 DELETE FROM payment_shopping_cart 268 WHERE session_id = %s',
274 $statement = $this->db->manipulateF(
' 275 DELETE FROM payment_shopping_cart 276 WHERE customer_id = %s',
277 array(
'integer'), array($this->user_obj->getId())
◆ getEntries()
ilPaymentShoppingCart::getEntries |
( |
|
$a_pay_method = 0 | ) |
|
Definition at line 77 of file class.ilPaymentShoppingCart.php.
Referenced by getShoppingCart().
79 if ($a_pay_method == 0)
81 return $this->sc_entries ? $this->sc_entries : array();
85 $tmp_entries = array();
86 foreach($this->sc_entries as $entry)
88 if ($entry[
'pay_method'] == $a_pay_method)
90 $tmp_entries[$entry[
'psc_id']] = $entry;
◆ getEntry()
ilPaymentShoppingCart::getEntry |
( |
|
$a_pobject_id | ) |
|
Definition at line 155 of file class.ilPaymentShoppingCart.php.
References $ilUser, $res, and getSessionId().
159 if(ANONYMOUS_USER_ID == $ilUser->getId())
161 $res = $this->db->queryf(
' 162 SELECT * FROM payment_shopping_cart 163 WHERE session_id = %s 164 AND pobject_id = %s',
165 array(
'text',
'integer'),
170 $res = $this->db->queryf(
' 171 SELECT * FROM payment_shopping_cart 172 WHERE customer_id = %s 173 AND pobject_id = %s',
174 array(
'integer',
'integer'),
175 array($this->user_obj->getId(), $a_pobject_id));
179 return $this->db->fetchAssoc(
$res);
◆ getPobjectId()
ilPaymentShoppingCart::getPobjectId |
( |
| ) |
|
◆ getPriceId()
ilPaymentShoppingCart::getPriceId |
( |
| ) |
|
◆ getSessionId()
ilPaymentShoppingCart::getSessionId |
( |
| ) |
|
◆ getShoppingCart()
ilPaymentShoppingCart::getShoppingCart |
( |
|
$a_pay_method = 0 | ) |
|
Definition at line 419 of file class.ilPaymentShoppingCart.php.
References $lng, ilPaymentPrices\_getPrice(), ilPaymentPrices\_getPriceString(), getEntries(), ilObjectFactory\getInstanceByRefId(), and ilShopVats\getRate().
Referenced by getTotalAmountValue().
422 if(!count($items = $this->
getEntries($a_pay_method)))
429 foreach($items as $item)
431 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
435 $f_result[$counter][
"psc_id"] = $item[
'psc_id'];
436 $f_result[$counter][
"pobject_id"] = $item[
'pobject_id'];
439 $f_result[$counter][
"obj_id"] = $tmp_obj->getId();
440 $f_result[$counter][
"type"] = $tmp_obj->getType();
441 $f_result[$counter][
"object_title"] = $tmp_obj->getTitle();
446 $f_result[$counter][
"obj_id"] =
'';
447 $f_result[$counter][
"type"] =
'';
448 $f_result[$counter][
"object_title"] = $lng->txt(
'object_deleted');
454 $price = number_format($price_data[
'price'], 2,
'.',
'');
456 $f_result[$counter][
"price"] = $price;
457 $f_result[$counter][
"price_string"] = $price_string;
458 $f_result[$counter][
'extension'] = $price_data[
'extension'];
460 require_once
'./Services/Payment/classes/class.ilShopVats.php';
461 $oVAT =
new ilShopVats((
int)$tmp_pobject->getVatId());
462 $f_result[$counter][
'vat_rate'] = $oVAT->
getRate();
463 $f_result[$counter][
'vat_unit'] = $tmp_pobject->getVat($price);
465 $f_result[$counter][
"duration"] = $price_data[
"duration"];
466 $f_result[$counter][
'unlimited_duration'] = $price_data[
'unlimited_duration'];
468 $f_result[$counter][
"price_type"] = $price_data[
"price_type"];
469 $f_result[$counter][
"duration_from"] = $price_data[
"duration_from"];
470 $f_result[$counter][
"duration_until"] = $price_data[
"duration_until"];
471 $f_result[$counter][
"description"] = $price_data[
"description"];
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getPrice($a_price_id)
static _getPriceString($a_price_id)
◆ getShoppingcartEntries()
static ilPaymentShoppingCart::getShoppingcartEntries |
( |
|
$a_paymethod = null | ) |
|
|
static |
- Parameters
-
integer | null | $a_paymethod | |
- Returns
- bool
Definition at line 601 of file class.ilPaymentShoppingCart.php.
References $ilDB, $ilUser, $res, and $row.
605 $user_id = $ilUser->getId();
607 if($user_id == ANONYMOUS_USER_ID)
613 if($a_paymethod != null)
615 $res = $ilDB->queryF(
' 616 SELECT psc_id, ref_id, vat_rate, duration, currency, price, unlimited_duration, extension, duration_from, duration_until, description,price_type, pay_method 617 FROM payment_shopping_cart psc 618 LEFT JOIN payment_prices pp ON psc.price_id 619 LEFT JOIN payment_objects po ON psc.pobject_id 620 LEFT JOIN payment_vats pv ON po.vat_id 621 WHERE customer_id = %s 623 AND pay_method = %s',
624 array(
'integer',
'integer',
'integer'), array($user_id, 1, $a_paymethod));
629 $res = $ilDB->queryF(
' 630 SELECT psc_id, ref_id, vat_rate, duration, currency, price, unlimited_duration, extension, duration_from, duration_until, description, price_type, pay_method 631 FROM payment_shopping_cart psc 632 LEFT JOIN payment_prices pp ON psc.price_id 633 LEFT JOIN payment_objects po ON psc.pobject_id 634 LEFT JOIN payment_vats pv ON po.vat_id 635 WHERE customer_id = %s 637 array(
'integer',
'integer'), array($user_id, 1));
641 while(
$row = $ilDB->fetchAssoc(
$res))
◆ getTotalAmount()
ilPaymentShoppingCart::getTotalAmount |
( |
| ) |
|
◆ getTotalAmountValue()
ilPaymentShoppingCart::getTotalAmountValue |
( |
|
$a_pay_method = 0 | ) |
|
◆ getVat()
ilPaymentShoppingCart::getVat |
( |
|
$a_amount = 0 , |
|
|
|
$a_pobject_id = 0 |
|
) |
| |
Definition at line 494 of file class.ilPaymentShoppingCart.php.
References $ilDB, $res, and $row.
498 include_once
'./Services/Payment/classes/class.ilShopVats.php';
500 $res = $ilDB->queryF(
' 501 SELECT * FROM payment_objects WHERE pobject_id = %s',
502 array(
'integer'), array($a_pobject_id));
504 while(
$row = $ilDB->fetchObject(
$res))
506 $this->vat_id =
$row->vat_id;
509 $res = $ilDB->queryF(
' 510 SELECT * FROM payment_vats WHERE vat_id = %s',
511 array(
'integer'),array($this->vat_id));
513 while(
$row = $ilDB->fetchObject(
$res))
515 $this->vat_rate =
$row->vat_rate;
517 return (
float) ($a_amount - (round(($a_amount / (1 + ($this->vat_rate / 100.0))) * 100) / 100));
◆ isInShoppingCart()
ilPaymentShoppingCart::isInShoppingCart |
( |
|
$a_pobject_id | ) |
|
Definition at line 128 of file class.ilPaymentShoppingCart.php.
References $ilUser, $res, $session_id, and getSessionId().
134 if(ANONYMOUS_USER_ID == $ilUser->getId())
136 $res = $this->db->queryf(
' 137 SELECT * FROM payment_shopping_cart 138 WHERE session_id = %s 139 AND pobject_id = %s',
140 array(
'text',
'integer'),
145 $res = $this->db->queryf(
' 146 SELECT * FROM payment_shopping_cart 147 WHERE customer_id = %s 148 AND pobject_id = %s',
149 array(
'integer',
'integer'),
150 array($this->user_obj->getId(), $a_pobject_id));
152 return $res->numRows() ? true :
false;
◆ setPobjectId()
ilPaymentShoppingCart::setPobjectId |
( |
|
$a_pobject_id | ) |
|
◆ setPriceId()
ilPaymentShoppingCart::setPriceId |
( |
|
$a_price_id | ) |
|
◆ setSessionId()
ilPaymentShoppingCart::setSessionId |
( |
|
$a_session_id | ) |
|
◆ setTotalAmount()
ilPaymentShoppingCart::setTotalAmount |
( |
|
$a_total_amount | ) |
|
◆ update()
ilPaymentShoppingCart::update |
( |
|
$a_psc_id | ) |
|
Definition at line 225 of file class.ilPaymentShoppingCart.php.
References $ilUser, __read(), getPobjectId(), getPriceId(), and getSessionId().
228 if(ANONYMOUS_USER_ID == $ilUser->getId())
230 $this->db->update(
'payment_shopping_cart',
231 array(
'pobject_id'=> array(
'integer', $this->
getPobjectId()),
232 'price_id' => array(
'integer', $this->
getPriceId()),
234 array(
'psc_id' => array(
'integer', (
int)$a_psc_id)));
239 $this->db->update(
'payment_shopping_cart',
240 array(
'customer_id' => array(
'integer', $this->user_obj->getId()),
241 'pobject_id' => array(
'integer', $this->
getPobjectId()),
242 'price_id' => array(
'integer', $this->
getPriceId()),
244 array(
'psc_id' => array(
'integer', (
int)$a_psc_id)));
◆ $coupon_obj
ilPaymentShoppingCart::$coupon_obj = null |
◆ $db
ilPaymentShoppingCart::$db = null |
◆ $pobject_id
ilPaymentShoppingCart::$pobject_id = null |
◆ $price_id
ilPaymentShoppingCart::$price_id = null |
◆ $sc_entries
ilPaymentShoppingCart::$sc_entries = array() |
◆ $session_id
ilPaymentShoppingCart::$session_id =null |
◆ $total_amount
ilPaymentShoppingCart::$total_amount = null |
◆ $user_obj
ilPaymentShoppingCart::$user_obj = null |
◆ $vat_id
ilPaymentShoppingCart::$vat_id = null |
◆ $vat_rate
ilPaymentShoppingCart::$vat_rate = 0 |
The documentation for this class was generated from the following file: