PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Framework
/
Helpers
<?php namespace WilokeListingTools\Framework\Helpers; class ProductSkeleton { private $productId; /** * @var \WC_Product */ private $oProduct; private $thumbnail = 'thumbnail'; /** * @param $productId * * @return $this */ public function setProductId($productId) { $this->productId = $productId; return $this; } /** * @param $thumbnail * * @return $this */ private function setThumbnail($thumbnail) { $this->thumbnail = $thumbnail; return $this; } private function getProduct() { $this->oProduct = wc_get_product($this->productId); return $this; } private function getID() { return $this->oProduct->get_id(); } private function getTitle() { return $this->oProduct->get_title(); } private function getThumbnail() { return get_the_post_thumbnail_url($this->getID(), $this->thumbnail); } private function getSalePriceHTML() { $salePrice = $this->getSalePrice(); return empty($salePrice) ? '' : wc_price($salePrice); } private function getSalePrice() { return floatval($this->oProduct->get_sale_price()); } private function getRegularPriceHTML() { $regularPrice = $this->getRegularPrice(); return empty($regularPrice) ? '' : wc_price($regularPrice); } private function getRegularPrice() { return floatval($this->oProduct->get_regular_price()); } private function getPrice() { return floatval($this->oProduct->get_price()); } private function getPriceHTML() { $price = $this->getPrice(); return empty($price) ? '' : wc_price($price); } private function getAverageRating() { return number_format($this->oProduct->get_average_rating(), 2); } private function getRatingCounts() { return intval($this->oProduct->get_rating_counts()); } private function getCartKey() { return WooCommerce::getCartKey($this->productId); } private function getDataAverageRating() { return $this->getAverageRating(); } /** * @param array $aPluck * * @return array|\WP_Error */ public function get($aPluck = []) { if (empty($aPluck)) { $aPluck = [ 'ID', 'title', 'thumbnail', 'salePriceHTML', 'salePrice', 'regularPriceHTML', 'regularPrice', 'priceHTML', 'price', 'averageRating', 'ratingCounts', 'cartKey' ]; } $this->getProduct(); if (empty($this->oProduct) || is_wp_error($this->oProduct)) { return new \WP_Error('broke', esc_html__('The product is no longer available', 'wiloke-listing-tools')); } $aResponse = []; foreach ($aPluck as $pluck) { $method = 'get'.ucfirst($pluck); if (method_exists($this, $method)) { $aResponse[$pluck] = $this->{$method}(); } else { $aResponse[$pluck] = ''; } } return $aResponse; } }
[+]
..
[-] SearchFieldSkeleton.php
[edit]
[-] FileSystem.php
[edit]
[-] Response.php
[edit]
[-] GetWilokeSubmission.php
[edit]
[-] AbstractSkeleton.php
[edit]
[-] InheritCMB2Styles.php
[edit]
[-] ReviewSkeleton.php
[edit]
[-] RestaurantMenu.php
[edit]
[-] WooCommerce.php
[edit]
[-] MapHelpers.php
[edit]
[-] .DS_Store
[edit]
[-] Message.php
[edit]
[-] GetSettings.php
[edit]
[-] QueryHelper.php
[edit]
[+]
Collection
[-] Inc.php
[edit]
[-] UserSkeleton.php
[edit]
[-] Firebase.php
[edit]
[-] Repository.php
[edit]
[-] DebugStatus.php
[edit]
[-] MapFactory.php
[edit]
[-] SetSettings.php
[edit]
[-] AddListingFieldSkeleton.php
[edit]
[-] VideoHelper.php
[edit]
[-] SearchFormSkeleton.php
[edit]
[-] PostSkeleton.php
[edit]
[-] KCHelpers.php
[edit]
[-] ProductSkeleton.php
[edit]
[-] QRCodeGenerator.php
[edit]
[-] HTML.php
[edit]
[-] Time.php
[edit]
[-] PlanHelper.php
[edit]
[-] SemanticUi.php
[edit]
[-] AjaxMsg.php
[edit]
[-] Logger.php
[edit]
[-] Cookie.php
[edit]
[-] Validation.php
[edit]
[-] GalleryHelper.php
[edit]
[-] AuthorSkeleton.php
[edit]
[-] General.php
[edit]
[-] Submission.php
[edit]
[-] TermSetting.php
[edit]