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->addAction('wp_ajax_jigoshop.admin.product.find', array($this, 'ajaxFindProduct'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.product.save_attribute', array($this, 'ajaxSaveAttribute'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.product.remove_attribute', array($this, 'ajaxRemoveAttribute'), 10, 0); $that = $this; $wp->addAction('add_meta_boxes_' . Types::PRODUCT, function () use($wp, $that) { $wp->addMetaBox('jigoshop-product-data', __('Product Data', 'jigoshop'), array($that, 'box'), Types::PRODUCT, 'normal', 'high'); $wp->addMetaBox('jigoshop-product-attachments', __('Attachments', 'jigoshop'), array($that, 'attachmentsBox'), Types::PRODUCT, 'side', 'low'); $wp->removeMetaBox('commentstatusdiv', null, 'normal'); }); $this->menu = $menu = $this->wp->applyFilters('jigoshop\\admin\\product\\menu', array('general' => array('label' => __('General', 'jigoshop'), 'visible' => true), 'advanced' => array('label' => __('Advanced', 'jigoshop'), 'visible' => array(Simple::TYPE, Virtual::TYPE)), 'attributes' => array('label' => __('Attributes', 'jigoshop'), 'visible' => true), 'stock' => array('label' => __('Stock', 'jigoshop'), 'visible' => array(Simple::TYPE, Virtual::TYPE)), 'sales' => array('label' => __('Sales', 'jigoshop'), 'visible' => array(Simple::TYPE, Virtual::TYPE)))); $wp->addAction('admin_enqueue_scripts', function () use($wp, $menu, $that) { if ($wp->getPostType() == Types::PRODUCT) { Styles::add('jigoshop.vendors.select2', \JigoshopInit::getUrl() . '/assets/css/vendors/select2.css', array('jigoshop.admin.product')); Styles::add('jigoshop.vendors.datepicker', \JigoshopInit::getUrl() . '/assets/css/vendors/datepicker.css', array('jigoshop.admin.product')); Styles::add('jigoshop.admin.product', \JigoshopInit::getUrl() . '/assets/css/admin/product.css'); Scripts::add('jigoshop.vendors.select2', \JigoshopInit::getUrl() . '/assets/js/vendors/select2.js', array('jquery', 'jigoshop.admin.product')); Scripts::add('jigoshop.vendors.bs_tab_trans_tooltip_collapse', \JigoshopInit::getUrl() . '/assets/js/vendors/bs_tab_trans_tooltip_collapse.js', array('jquery', 'jigoshop.admin.product')); Scripts::add('jigoshop.vendors.datepicker', \JigoshopInit::getUrl() . '/assets/js/vendors/datepicker.js', array('jquery', 'jigoshop.admin.product')); Scripts::add('jigoshop.admin.product', \JigoshopInit::getUrl() . '/assets/js/admin/product.js', array('jquery', 'jigoshop.helpers', 'jquery-ui-sortable')); Scripts::localize('jigoshop.admin.product', 'jigoshop_admin_product', array('i18n' => array('saved' => __('Changes saved.', 'jigoshop'), 'attribute_removed' => __('Attribute successfully removed.', 'jigoshop'), 'confirm_remove' => __('Are you sure?', 'jigoshop'), 'invalid_attribute' => __('Invalid attribute, please select another one.', 'jigoshop'), 'attribute_without_label' => __('Please provide attribute label.', 'jigoshop')), 'menu' => array_map(function ($item) { return $item['visible']; }, $menu), 'attachments' => $that->getAttachments())); $wp->doAction('jigoshop\\admin\\product\\assets', $wp); } }, 5); }
public function __construct(Wordpress $wp, Options $options, OrderServiceInterface $orderService, ProductServiceInterface $productService, CustomerServiceInterface $customerService, ShippingServiceInterface $shippingService) { $this->wp = $wp; $this->options = $options; $this->orderService = $orderService; $this->productService = $productService; $this->customerService = $customerService; $this->shippingService = $shippingService; $wp->addAction('admin_enqueue_scripts', function () use($wp, $options) { if ($wp->getPostType() == Types::ORDER) { Styles::add('jigoshop.admin.order', \JigoshopInit::getUrl() . '/assets/css/admin/order.css'); Scripts::add('jigoshop.admin.order', \JigoshopInit::getUrl() . '/assets/js/admin/order.js', array('jquery', 'jigoshop.helpers')); Styles::add('jigoshop.vendors.datetimepicker', \JigoshopInit::getUrl() . '/assets/css/vendors/datetimepicker.css'); Scripts::add('jigoshop.vendors.datetimepicker', \JigoshopInit::getUrl() . '/assets/js/vendors/datetimepicker.js'); Scripts::localize('jigoshop.admin.order', 'jigoshop_admin_order', array('tax_shipping' => $options->get('tax.shipping'), 'ship_to_billing' => $options->get('shipping.only_to_billing'))); } }); $wp->addAction('wp_ajax_jigoshop.admin.order.add_product', array($this, 'ajaxAddProduct'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.update_product', array($this, 'ajaxUpdateProduct'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.remove_product', array($this, 'ajaxRemoveProduct'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.change_country', array($this, 'ajaxChangeCountry'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.change_state', array($this, 'ajaxChangeState'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.change_postcode', array($this, 'ajaxChangePostcode'), 10, 0); $wp->addAction('wp_ajax_jigoshop.admin.order.change_shipping_method', array($this, 'ajaxChangeShippingMethod'), 10, 0); $that = $this; $wp->addAction('add_meta_boxes_' . Types::ORDER, function () use($wp, $orderService, $that) { $post = $wp->getGlobalPost(); /** @var \Jigoshop\Entity\Order $order */ $order = $orderService->findForPost($post); $wp->addMetaBox('jigoshop-order-data', $order->getTitle(), array($that, 'dataBox'), Types::ORDER, 'normal', 'high'); $wp->addMetaBox('jigoshop-order-items', __('Order Items', 'jigoshop'), array($that, 'itemsBox'), Types::ORDER, 'normal', 'high'); $wp->addMetaBox('jigoshop-order-totals', __('Order Totals', 'jigoshop'), array($that, 'totalsBox'), Types::ORDER, 'normal', 'high'); $wp->removeMetaBox('commentstatusdiv', null, 'normal'); $wp->removeMetaBox('submitdiv', Types::ORDER, 'side'); $wp->addMetaBox('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); $wp->addMetaBox('submitdiv', __('Order Actions', 'jigoshop'), array($that, 'actionsBox'), Types::ORDER, 'side', 'default'); }); }