/** * Displays the product data box, tabbed, with several panels covering price, stock etc * * @since 1.0 */ public function box() { $post = $this->wp->getGlobalPost(); $coupon = $this->couponService->findForPost($post); $methods = array(); foreach ($this->paymentService->getAvailable() as $method) { /** @var $method Method */ $methods[$method->getId()] = $method->getName(); } Render::output('admin/coupon/box', array('coupon' => $coupon, 'types' => $this->couponService->getTypes(), 'paymentMethods' => $methods)); }
/** * @return bool Whether current method is enabled and able to work. */ public function isEnabled() { $cart = $this->cartService->getCurrent(); $post = $this->wp->getGlobalPost(); if ($post === null || $post->post_type != Types::ORDER) { $customer = $cart->getCustomer(); } else { // TODO: Get rid of this hack for customer fetching $customer = unserialize($this->wp->getPostMeta($post->ID, 'customer', true)); } return $this->options['enabled'] && ($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries'])); }
/** * @return bool Whether current method is enabled and able to work. */ public function isEnabled() { $cart = $this->cartService->getCurrent(); $post = $this->wp->getGlobalPost(); if ($post === null || $post->post_type != Types::ORDER) { $customer = $cart->getCustomer(); } else { // TODO: Get rid of this hack for customer fetching $customer = maybe_unserialize($this->wp->getPostMeta($post->ID, 'customer', true)); } if (empty($customer)) { return $this->options['enabled']; } return $this->options['enabled'] && $customer->getShippingAddress()->getCountry() == $this->baseCountry; }
/** * @return bool Whether current method is enabled and able to work. */ public function isEnabled() { $cart = $this->cartService->getCurrent(); $post = $this->wp->getGlobalPost(); if ($post === null || $post->post_type != Types::ORDER) { $customer = $cart->getCustomer(); } else { // TODO: Get rid of this hack for customer fetching $customer = unserialize($this->wp->getPostMeta($post->ID, 'customer', true)); } $freeShippingCoupon = array_reduce($cart->getCoupons(), function ($value, $coupon) { /** @var $coupon Coupon */ return $value || $coupon->isFreeShipping(); }, false); return $this->options['enabled'] && ($freeShippingCoupon || $cart->getProductSubtotal() >= $this->options['minimum'] && ($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries']))); }
public function getAttachments() { $post = $this->wp->getGlobalPost(); /** @var \Jigoshop\Entity\Product $product */ $product = $this->productService->findForPost($post); return $this->productService->getAttachments($product); }
public function displayColumn($column) { $post = $this->wp->getGlobalPost(); if ($post === null) { return; } /** @var Product | Product\Variable $product */ $product = $this->productService->find($post->ID); switch ($column) { case 'thumbnail': echo ProductHelper::getFeaturedImage($product, Options::IMAGE_THUMBNAIL); break; case 'price': echo ProductHelper::getPriceHtml($product); break; case 'featured': echo ProductHelper::isFeatured($product); break; case 'type': echo $this->type->getType($product->getType())->getName(); break; case 'sku': echo $this->getVariableAdditionalInfo($product, 'sku'); break; case 'stock': echo $this->getVariableAdditionalInfo($product, 'stock'); break; case 'creation': $timestamp = strtotime($post->post_date); echo Formatter::date($timestamp); if ($product->isVisible()) { echo '<br /><strong>' . __('Visible in', 'jigoshop') . '</strong>: '; switch ($product->getVisibility()) { case ProductEntity::VISIBILITY_SEARCH: echo __('Search only', 'jigoshop'); break; case ProductEntity::VISIBILITY_CATALOG: echo __('Catalog only', 'jigoshop'); break; case ProductEntity::VISIBILITY_PUBLIC: echo __('Catalog and search', 'jigoshop'); break; } } break; } }
public function displayColumn($column) { $post = $this->wp->getGlobalPost(); if ($post === null) { return; } /** @var \Jigoshop\Entity\Coupon $coupon */ $coupon = $this->couponService->find($post->ID); switch ($column) { case 'code': echo $coupon->getCode(); break; case 'type': echo $this->couponService->getType($coupon); break; case 'amount': echo ProductHelper::formatNumericPrice($coupon->getAmount()); break; case 'usage_limit': echo $coupon->getUsageLimit(); break; case 'usage': echo $coupon->getUsage(); break; case 'from': $from = $coupon->getFrom(); if ($from) { echo Formatter::date($from->getTimestamp()); } break; case 'to': $to = $coupon->getTo(); if ($to) { echo Formatter::date($to->getTimestamp()); } break; case 'is_individual': echo sprintf('<span class="glyphicon %s" aria-hidden="true"></span> <span class="sr-only">%s</span>', $coupon->isIndividualUse() ? 'glyphicon-ok' : 'glyphicon-remove', $coupon->isIndividualUse() ? __('Yes', 'jigoshop') : __('No', 'jigoshop')); break; } }
public function displayTitle($actions) { $post = $this->wp->getGlobalPost(); // Remove "Quick edit" as we won't use it. unset($actions['inline hide-if-no-js']); if ($post->post_type == Types::ORDER) { $fullFormat = _x('Y/m/d g:i:s A', 'time', 'jigoshop'); $format = _x('Y/m/d', 'time', 'jigoshop'); $fullDate = $this->wp->getHelpers()->mysql2date($fullFormat, $post->post_date); $date = $this->wp->getHelpers()->mysql2date($format, $post->post_date); echo '<time title="' . $fullDate . '">' . $this->wp->applyFilters('post_date_column_time', $date, $post) . '</time>'; } return $actions; }
public function actionsBox() { $post = $this->wp->getGlobalPost(); /** @var \Jigoshop\Entity\Order $order */ $order = $this->orderService->findForPost($post); $delete_text = ''; if (current_user_can("delete_post", $post->ID)) { if (!EMPTY_TRASH_DAYS) { $delete_text = __('Delete Permanently'); } else { $delete_text = __('Move to Trash'); } } $this->renderModifiedPublishBoxContent($post); Render::output('admin/order/actionsBox', array('order' => $order, 'delete_text' => $delete_text)); }
/** * Displays the product data box, tabbed, with several panels covering price, stock etc * * @since 1.0 */ public function variablesBox() { $post = $this->wp->getGlobalPost(); $email = $this->emailService->findForPost($post); Render::output('admin/email/variablesBox', array('email' => $email, 'emails' => $this->emailService->getMails())); }
public function render() { $post = $this->wp->getGlobalPost(); $product = $this->productService->findForPost($post); return Render::get('shop/product', array('product' => $product, 'messages' => $this->messages)); }
/** * @param Wordpress $wp */ public function addFrontendAssets(Wordpress $wp) { $post = $wp->getGlobalPost(); $product = $this->productService->findForPost($post); if ($product instanceof Product\Variable) { $variations = array(); foreach ($product->getVariations() as $variation) { /** @var $variation Product\Variable\Variation */ $variations[$variation->getId()] = array('price' => $variation->getProduct()->getPrice(), 'html' => array('price' => \Jigoshop\Helper\Product::formatPrice($variation->getProduct()->getPrice())), 'attributes' => array()); foreach ($variation->getAttributes() as $attribute) { /** @var $attribute Product\Variable\Attribute */ $variations[$variation->getId()]['attributes'][$attribute->getAttribute()->getId()] = $attribute->getValue(); } } Styles::add('jigoshop.product.variable', \JigoshopInit::getUrl() . '/assets/css/shop/product/variable.css'); Scripts::add('jigoshop.product.variable', \JigoshopInit::getUrl() . '/assets/js/shop/product/variable.js', array('jquery')); Scripts::localize('jigoshop.product.variable', 'jigoshop_product_variable', array('variations' => $variations)); } }