/**
  * @singleton method used to instantiate class object
  * @access    public
  * @param EE_Line_Item $grand_total
  * @return \EE_Cart
  */
 public static function instance(EE_Line_Item $grand_total = null)
 {
     EE_Registry::instance()->load_helper('Line_Item');
     // rest cart with new grand total ?
     if (!empty($grand_total)) {
         self::$_instance = new self($grand_total);
     }
     // or maybe retrieve an existing one ?
     if (!self::$_instance instanceof EE_Cart) {
         // try getting the cart out of the session
         self::$_instance = EE_Registry::instance()->SSN->cart();
     }
     // verify that cart is ok and grand total line item exists
     if (!self::$_instance instanceof EE_Cart || !self::$_instance->_grand_total instanceof EE_Line_Item) {
         self::$_instance = new self($grand_total);
     }
     self::$_instance->get_grand_total();
     // once everything is all said and done, save the cart to the EE_Session
     add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * @singleton method used to instantiate class object
  * @access    public
  * @param EE_Line_Item $grand_total
  * @param EE_Session $session
  * @return \EE_Cart
  */
 public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null)
 {
     if (!empty($grand_total)) {
         self::$_instance = new self($grand_total, $session);
     }
     // or maybe retrieve an existing one ?
     if (!self::$_instance instanceof EE_Cart) {
         // try getting the cart out of the session
         $saved_cart = $session instanceof EE_Session ? $session->cart() : null;
         self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session);
         unset($saved_cart);
     }
     // verify that cart is ok and grand total line item exists
     if (!self::$_instance instanceof EE_Cart || !self::$_instance->_grand_total instanceof EE_Line_Item) {
         self::$_instance = new self($grand_total, $session);
     }
     self::$_instance->get_grand_total();
     // once everything is all said and done, save the cart to the EE_Session
     add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
     return self::$_instance;
 }
 /**
  *    _get_payment_info
  *
  * @access    public
  * @param EE_Cart $cart
  * @return    array
  */
 public function _get_payment_info(EE_Cart $cart)
 {
     EEH_Autoloader::register_line_item_filter_autoloaders();
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor(apply_filters('FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection()), $cart->get_grand_total());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     //$this->checkout->line_item_filters();
     $Line_Item_Display = new EE_Line_Item_Display('spco');
     return array('payment_info' => $Line_Item_Display->display_line_item($filtered_line_item_tree), 'cart_total' => $filtered_line_item_tree->total());
 }