/** * Finds item for specified WordPress post. * * @param $post \WP_Post WordPress post. * @return Order Item found. */ public function findForPost($post) { if (!isset($this->objects[$post->ID])) { $this->objects[$post->ID] = $this->service->findForPost($post); } return $this->objects[$post->ID]; }
/** * Finds item for specified WordPress post. * * @param $post \WP_Post WordPress post. * @return Order Item found. */ public function findForPost($post) { if (!isset($this->objects[$post->ID])) { $cachedOrder = $this->instanceCache->getItem('order_' . $post->ID); if ($cachedOrder->get() instanceof Order) { $this->objects[$post->ID] = $cachedOrder->get(); } else { $this->objects[$post->ID] = $this->service->findForPost($post); $cachedOrder->set($this->objects[$post->ID]); $this->instanceCache->save($cachedOrder); } } return $this->objects[$post->ID]; }
/** * Replace order title. * @param $title * * @return mixed */ public function replaceTitle($title) { $post = $this->wp->getGlobalPost(); if ($post->post_type == Types::ORDER) { /** @var Entity $order */ $order = $this->orderService->findForPost($post); $title = sprintf(__('Order #%s', 'jigoshop'), $order->getNumber()); } return $title; }
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)); }