/** * @return C_Pricelist_Source_Manager */ static function get_instance() { if (!isset(self::$_instance)) { self::$_instance = new C_Pricelist_Source_Manager(); } return self::$_instance; }
/** * Gets all items from all sources for the pricelist, optionally filtered by an image * @param null $image * @return array */ function get_items($image = NULL) { $retval = array(); foreach (C_Pricelist_Source_Manager::get_instance()->get_ids() as $id) { $method = "get_{$id}_items"; if ($this->has_method($method)) { $items = $this->{$method}($image); $retval = array_merge($retval, $items); } } return $retval; }
function initialize() { parent::initialize(); if (!is_admin()) { // Add lightbox components if (version_compare(NGG_PLUGIN_VERSION, '2.0.67') >= 0) { M_NextGen_Pro_Lightbox::add_component('photocrati-add_to_cart', 'C_NextGen_Pro_Add_To_Cart'); } else { M_NextGen_Pro_Lightbox_Legacy::add_component('photocrati-add_to_cart', 'C_NextGen_Pro_Add_To_Cart'); } // Add trigger $triggers = C_Displayed_Gallery_Trigger_Manager::get_instance(); $triggers->add(NGG_ECOMMERCE_TRIGGER, 'C_NextGen_Pro_Ecommerce_Trigger'); C_NextGen_Shortcode_Manager::add('ngg_pro_cart_count', array(&$this, 'render_cart_count')); C_NextGen_Shortcode_Manager::add('ngg_pro_checkout', array(&$this, 'render_checkout_form')); C_NextGen_Shortcode_Manager::add('ngg_pro_digital_downloads', array(&$this, 'render_digital_downloads')); C_NextGen_Shortcode_Manager::add('ngg_pro_order_details', array(&$this, 'render_order_details')); C_NextGen_Shortcode_Manager::add('ngg_pro_verify_order', array(&$this, 'render_order_verification')); } // Add pricelist sources $sources = C_Pricelist_Source_Manager::get_instance(); $sources->register(NGG_PRO_MANUAL_PRICELIST_SOURCE, array('title' => __('Manual Pricelist', 'nextgen-gallery-pro'), 'shipping_method' => 'C_NextGen_Pro_Flat_Rate_Shipping_Calculator', 'settings_field' => 'manual_settings')); $sources->register(NGG_PRO_DIGITAL_DOWNLOADS_SOURCE, array('title' => __('Digital Downloads', 'nextgen-gallery-pro'), 'shipping_method' => NULL, 'settings_field' => 'digital_download_settings')); }
/** * Determines if the cart has shippable items * @return bool */ function has_shippable_items() { $retval = FALSE; $sources = C_Pricelist_Source_Manager::get_instance(); foreach ($this->_state as $image_id => $image_props) { if (!isset($image_props->items)) { $image_props->items = array(); } foreach (array_keys($image_props->items) as $source) { if ($sources->get($source, 'shipping_method')) { $retval = TRUE; break; } } } return $retval; }