Beispiel #1
0
 /**
  * Initializes product type.
  *
  * @param Wordpress $wp           WordPress Abstraction Layer
  * @param array     $enabledTypes List of all available types.
  */
 public function initialize(Wordpress $wp, array $enabledTypes)
 {
     $wp->addFilter('jigoshop\\cart\\add', array($this, 'addToCart'), 10, 2);
     $wp->addFilter('jigoshop\\core\\types\\variable\\subtypes', array($this, 'addVariableSubtype'), 10, 1);
     $wp->addFilter('jigoshop\\product\\get_stock', array($this, 'getStock'), 10, 2);
     $wp->addAction('jigoshop\\admin\\product\\assets', array($this, 'addAssets'), 10, 0);
 }
Beispiel #2
0
 /**
  * Initializes product type.
  *
  * @param Wordpress $wp           WordPress Abstraction Layer
  * @param array     $enabledTypes List of all available types.
  */
 public function initialize(Wordpress $wp, array $enabledTypes)
 {
     $wp->addFilter('jigoshop\\cart\\add', array($this, 'addToCart'), 10, 2);
     $wp->addFilter('jigoshop\\core\\types\\variable\\subtypes', array($this, 'addVariableSubtype'), 10, 1);
     $wp->addAction('jigoshop\\admin\\product\\assets', array($this, 'addAssets'), 10, 0);
     $wp->addFilter('jigoshop\\admin\\product\\menu', array($this, 'addProductMenu'));
     $wp->addFilter('jigoshop\\product\\tabs\\general', array($this, 'addToGeneralTab'), 10, 1);
     $wp->addAction('jigoshop\\admin\\variation', array($this, 'addVariationFields'), 10, 2);
 }
Beispiel #3
0
 public function __construct(Wordpress $wp)
 {
     $this->wp = $wp;
     $wp->addAction('init', array($this, 'registerOrderStatuses'));
     $wp->addFilter('post_updated_messages', array($this, 'updateMessages'));
     // Enable comments for all orders, disable pings
     $wp->addFilter('wp_insert_post_data', function ($data) {
         if ($data['post_type'] == Order::NAME) {
             $data['comment_status'] = 'open';
             $data['ping_status'] = 'closed';
         }
         return $data;
     });
 }
Beispiel #4
0
 private function getStateFromSession($id)
 {
     $state = array();
     $session = $this->session->getField(self::CART);
     if (isset($session[$id])) {
         $state = $session[$id];
         $state['customer'] = $this->customerService->getCurrent();
         if (isset($state['items'])) {
             $productService = $this->productService;
             $this->wp->addFilter('jigoshop\\internal\\order\\item', function ($value, $data) use($productService) {
                 return $productService->findForState($data);
             }, 10, 2);
             $state['items'] = unserialize($state['items']);
         }
         if (isset($state['shipping'])) {
             $shipping = $state['shipping'];
             if (!empty($shipping['method'])) {
                 $state['shipping'] = array('method' => $this->shippingService->findForState($shipping['method']), 'price' => $shipping['price'], 'rate' => isset($shipping['rate']) ? $shipping['rate'] : null);
             }
         }
         if (isset($state['payment']) && !empty($state['payment'])) {
             $state['payment'] = $this->paymentService->get($state['payment']);
         }
     }
     return $state;
 }
Beispiel #5
0
 public function __construct(Wordpress $wp, Options $options, ProductServiceInterface $productService, CartServiceInterface $cartService, Messages $messages)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->productService = $productService;
     $this->cartService = $cartService;
     $this->messages = $messages;
     Styles::add('jigoshop.vendors.colorbox', \JigoshopInit::getUrl() . '/assets/css/vendors/colorbox.css');
     Styles::add('jigoshop.vendors.select2', \JigoshopInit::getUrl() . '/assets/css/vendors/select2.css');
     Styles::add('jigoshop.shop.product', \JigoshopInit::getUrl() . '/assets/css/shop/product.css', array('jigoshop.shop', 'jigoshop.vendors.select2', 'jigoshop.vendors.colorbox'));
     if ($this->options->get('products.related')) {
         Styles::add('jigoshop.shop.related_products', \JigoshopInit::getUrl() . '/assets/css/shop/related_products.css', array('jigoshop.shop'));
     }
     Scripts::add('jigoshop.vendors.select2', \JigoshopInit::getUrl() . '/assets/js/vendors/select2.js', array('jquery'));
     Scripts::add('jigoshop.vendors.colorbox', \JigoshopInit::getUrl() . '/assets/js/vendors/colorbox.js', array('jquery'));
     Scripts::add('jigoshop.vendors.bs_tab_trans_tooltip_collapse', \JigoshopInit::getUrl() . '/assets/js/vendors/bs_tab_trans_tooltip_collapse.js', array('jquery'));
     Scripts::add('jigoshop.shop.product', \JigoshopInit::getUrl() . '/assets/js/shop/product.js', array('jquery', 'jigoshop.shop', 'jigoshop.vendors.select2', 'jigoshop.vendors.colorbox', 'jigoshop.vendors.bs_tab_trans_tooltip_collapse'));
     $wp->addFilter('jigoshop\\cart\\add', function ($item) use($productService) {
         /** @var $item Item */
         if ($item instanceof Item) {
             $item->setKey($productService->generateItemKey($item));
         }
         return $item;
     });
     $wp->addAction('jigoshop\\template\\product\\before_summary', array($this, 'productImages'), 10, 1);
     $wp->addAction('jigoshop\\template\\product\\after_summary', array($this, 'productTabs'), 10, 1);
     if ($this->options->get('products.related')) {
         $wp->addAction('jigoshop\\template\\product\\after_summary', array($this, 'relatedProducts'), 20, 1);
     }
     $wp->addAction('jigoshop\\template\\product\\tab_panels', array($this, 'productDescription'), 10, 2);
     $wp->addAction('jigoshop\\template\\product\\tab_panels', array($this, 'productAttributes'), 15, 2);
     $wp->addAction('jigoshop\\template\\product\\tab_panels', array($this, 'productDownloads'), 20, 2);
     $wp->doAction('jigoshop\\product\\assets', $wp);
 }
Beispiel #6
0
 public function __construct(Wordpress $wp, ProductServiceInterface $productService)
 {
     $this->wp = $wp;
     $this->productService = $productService;
     $wp->addFilter('jigoshop\\find\\product', array($this, 'fetch'));
     $wp->addAction('jigoshop\\admin\\product_attribute\\add', array($this, 'addAttributes'), 10, 2);
 }
Beispiel #7
0
 public function __construct(Wordpress $wp, Options $options)
 {
     $this->wp = $wp;
     $this->options = $options;
     $wp->addAction('init', array($this, 'initFix'));
     $wp->addFilter('rewrite_rules_array', array($this, 'fix'));
 }
Beispiel #8
0
 /**
  * @return array List of orders that are too long in Processing status.
  */
 public function findOldProcessing()
 {
     $this->wp->addFilter('posts_where', array($this, 'ordersFilter'));
     $query = new \WP_Query(array('post_status' => Order\Status::PROCESSING, 'post_type' => Types::ORDER, 'suppress_filters' => false, 'fields' => 'ids'));
     $results = $this->findByQuery($query);
     $this->wp->removeFilter('posts_where', array($this, 'ordersFilter'));
     return $results;
 }
Beispiel #9
0
 /**
  * Dummy constructor.
  * @param Wordpress $wp
  * @param Options $options
  * @param ProductServiceInterface $productService
  * @param CartServiceInterface $cartService
  * @param Messages $messages
  */
 public function __construct(Wordpress $wp, Options $options, ProductServiceInterface $productService, CartServiceInterface $cartService, Messages $messages)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->productService = $productService;
     $this->cartService = $cartService;
     $this->messages = $messages;
     $wp->addFilter('jigoshop\\cart\\add', function ($item) use($productService) {
         /** @var $item Item */
         $item->setKey($productService->generateItemKey($item));
         return $item;
     });
 }
Beispiel #10
0
 public function __construct(Wordpress $wp, Options $options, CouponServiceInterface $couponService)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->couponService = $couponService;
     $wp->addFilter(sprintf('manage_edit-%s_columns', Types::COUPON), array($this, 'columns'));
     $wp->addAction(sprintf('manage_%s_posts_custom_column', Types::COUPON), array($this, 'displayColumn'), 2);
     $wp->addAction('admin_enqueue_scripts', function () use($wp) {
         if ($wp->getPostType() == Types::COUPON) {
             $wp->doAction('jigoshop\\admin\\coupons\\assets', $wp);
         }
     });
 }
 public function __construct(Wordpress $wp, Options $options, ProductServiceInterface $productService, CartServiceInterface $cartService, Messages $messages)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->productService = $productService;
     $this->cartService = $cartService;
     $this->messages = $messages;
     $wp->addFilter('jigoshop\\cart\\add', function ($item) use($productService) {
         /** @var $item Item */
         $item->setKey($productService->generateItemKey($item));
         return $item;
     });
     Styles::add('jigoshop.shop.list', \JigoshopInit::getUrl() . '/assets/css/shop/list.css', array('jigoshop.shop'));
     Styles::add('jigoshop.vendors.select2', \JigoshopInit::getUrl() . '/assets/css/vendors/select2.css', array('jigoshop.shop'));
     Scripts::add('jigoshop.shop');
 }
Beispiel #12
0
 /**
  * Initializes product type.
  *
  * @param Wordpress $wp           WordPress Abstraction Layer
  * @param array     $enabledTypes List of all available types.
  */
 public function initialize(Wordpress $wp, array $enabledTypes)
 {
     $wp->addFilter('jigoshop\\cart\\add', array($this, 'addToCart'), 10, 2);
     $wp->addFilter('jigoshop\\emails\\order_item', array($this, 'emailLink'), 10, 3);
     $wp->addFilter('jigoshop\\core\\types\\variable\\subtypes', array($this, 'addVariableSubtype'), 10, 1);
     $wp->addAction('jigoshop\\order\\before\\' . Order\Status::PROCESSING, array($this, 'updateProcessingStatus'));
     $wp->addFilter('jigoshop\\product\\reduce_stock_status', array($this, 'reduceStockStatus'), 10, 2);
     $wp->addAction('jigoshop\\admin\\product\\assets', array($this, 'addAssets'), 10, 0);
     $wp->addFilter('jigoshop\\admin\\product\\menu', array($this, 'addProductMenu'));
     $wp->addFilter('jigoshop\\admin\\product\\tabs', array($this, 'addProductTab'), 10, 2);
     $wp->addAction('jigoshop\\admin\\variation', array($this, 'addVariationFields'), 10, 2);
 }
Beispiel #13
0
 public function __construct(Wordpress $wp, Options $options, Types\Product $type, ProductServiceInterface $productService)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->productService = $productService;
     $this->type = $type;
     $wp->addFilter(sprintf('manage_edit-%s_columns', Types::PRODUCT), array($this, 'columns'));
     $wp->addAction(sprintf('manage_%s_posts_custom_column', Types::PRODUCT), array($this, 'displayColumn'), 2);
     $wp->addAction('restrict_manage_posts', array($this, 'categoryFilter'));
     $wp->addAction('restrict_manage_posts', array($this, 'typeFilter'));
     $wp->addAction('pre_get_posts', array($this, 'setTypeFilter'));
     $wp->addAction('wp_ajax_jigoshop.admin.products.feature_product', array($this, 'ajaxFeatureProduct'));
     $wp->addAction('admin_enqueue_scripts', function () use($wp) {
         if ($wp->getPostType() == Types::PRODUCT) {
             Scripts::add('jigoshop.admin.products', \JigoshopInit::getUrl() . '/assets/js/admin/products.js', array('jquery', 'jigoshop.helpers'));
             Styles::add('jigoshop.admin.products_list', \JigoshopInit::getUrl() . '/assets/css/admin/products_list.css', array('jigoshop.admin'));
             $wp->doAction('jigoshop\\admin\\products\\assets', $wp);
         }
     });
 }
Beispiel #14
0
 public function __construct(Wordpress $wp, Options $options, OrderServiceInterface $orderService)
 {
     $this->wp = $wp;
     $this->options = $options;
     $this->orderService = $orderService;
     $wp->addFilter('request', array($this, 'request'));
     $wp->addFilter('the_title', array($this, 'replaceTitle'));
     $wp->addFilter('post_row_actions', array($this, 'displayTitle'));
     $wp->addFilter(sprintf('bulk_actions-edit-%s', Types::ORDER), array($this, 'bulkActions'));
     $wp->addFilter(sprintf('views_edit-%s', Types::ORDER), array($this, 'statusFilters'));
     $wp->addFilter(sprintf('manage_edit-%s_columns', Types::ORDER), array($this, 'columns'));
     $wp->addAction(sprintf('manage_%s_posts_custom_column', Types::ORDER), array($this, 'displayColumn'), 2);
     $wp->addAction(sprintf('manage_edit-%s_sortable_columns', Types::ORDER), array($this, 'disableSorting'));
     $wp->addAction('admin_enqueue_scripts', function () use($wp) {
         if ($wp->getPostType() == Types::ORDER) {
             Styles::add('jigoshop.admin.orders', \JigoshopInit::getUrl() . '/assets/css/admin/orders.css');
         }
     });
     Scripts::add('jigoshop.admin.page.orders_list', \JigoshopInit::getUrl() . '/assets/js/admin/orders.js', array('jquery-blockui'));
     $wp->addAction('wp_ajax_jigoshop.admin.orders.change_status', array($this, 'ajaxChangeStatus'), 10, 0);
 }
Beispiel #15
0
 public function run()
 {
     $this->wp->addFilter('query_vars', array($this, 'addQueryVars'), 0);
     $this->wp->addAction('init', array($this, 'addRewrite'), 1);
     $this->wp->addAction('parse_request', array($this, 'parseRequest'), 0);
 }
Beispiel #16
0
 /**
  * Initializes product type.
  *
  * @param Wordpress $wp           WordPress Abstraction Layer
  * @param array     $enabledTypes List of all available types.
  */
 public function initialize(Wordpress $wp, array $enabledTypes)
 {
     $wp->addFilter('jigoshop\\cart\\add', array($this, 'addToCart'), 10, 2);
     $wp->addFilter('jigoshop\\cart\\generate_item_key', array($this, 'generateItemKey'), 10, 2);
     $wp->addFilter('jigoshop\\checkout\\is_shipping_required', array($this, 'isShippingRequired'), 10, 2);
     $wp->addAction('jigoshop\\product\\assets', array($this, 'addFrontendAssets'), 10, 1);
     $wp->addFilter('jigoshop\\product\\get_stock', array($this, 'getStock'), 10, 2);
     $wp->addAction('jigoshop\\admin\\product\\assets', array($this, 'addAdminAssets'), 10, 1);
     $wp->addAction('jigoshop\\admin\\product\\attribute\\options', array($this, 'addVariableAttributeOptions'));
     $wp->addFilter('jigoshop\\admin\\product\\menu', array($this, 'addProductMenu'));
     $wp->addFilter('jigoshop\\admin\\product\\tabs', array($this, 'addProductTab'), 10, 2);
     $wp->addAction('wp_ajax_jigoshop.admin.product.add_variation', array($this, 'ajaxAddVariation'), 10, 0);
     $wp->addAction('wp_ajax_jigoshop.admin.product.save_variation', array($this, 'ajaxSaveVariation'), 10, 0);
     $wp->addAction('wp_ajax_jigoshop.admin.product.remove_variation', array($this, 'ajaxRemoveVariation'), 10, 0);
     $wp->addAction('wp_ajax_jigoshop.admin.product.set_variation_image', array($this, 'ajaxSetImageVariation'), 10, 0);
     $that = $this;
     $wp->addAction('jigoshop\\run', function () use($that, $wp, $enabledTypes) {
         $allowedSubtypes = $wp->applyFilters('jigoshop\\core\\types\\variable\\subtypes', array());
         $that->setAllowedSubtypes(array_filter($enabledTypes, function ($type) use($allowedSubtypes) {
             /** @var $type Type */
             return in_array($type->getId(), $allowedSubtypes);
         }));
     });
 }
Beispiel #17
0
 public function run()
 {
     $this->addEndpoints();
     $this->wp->addFilter('request', array($this, 'intercept'));
     $this->wp->addFilter('wp_nav_menu_objects', array($this, 'menu'));
 }