PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wp-all-export-pro
/
src
/
App
/
Field
<?php namespace Wpae\App\Field; class Gender extends Field { const SECTION = 'detailedInformation'; public function getValue($snippetData) { $detailedInformationData = $this->feed->getSectionFeedData(self::SECTION); if ($detailedInformationData['gender'] == 'selectProductTaxonomies') { $categoryData = $this->feed->getSectionFeedData(self::SECTION); $categoryId = $this->getProductCategoryId($this->getProduct()); if(isset($categoryData['genderCats'][$categoryId])) { return $categoryData['genderCats'][$categoryId]; } else { return ''; } } else if ($detailedInformationData['gender'] == self::SELECT_FROM_WOOCOMMERCE_PRODUCT_ATTRIBUTES) { if(isset($detailedInformationData['genderAttribute'])) { $genderAttribute = $detailedInformationData['genderAttribute']; } else { $genderAttribute = ''; } return $this->replaceSnippetsInValue($genderAttribute, $snippetData); } else if ($detailedInformationData['gender'] == self::CUSTOM_VALUE_TEXT) { return $this->replaceSnippetsInValue($detailedInformationData['genderCV'], $snippetData); } else if ($detailedInformationData['gender'] == 'autodetectBasedOnProductTaxonomies') { $menValues = array('men', 'man', 'male', 'gentleman', 'gents'); $womenValues = array('women', 'woman', 'female', 'ladies'); $unisexValues = array('unisex'); $product = $this->getProduct(); $autodetect = ''; $productCategories = get_the_terms($product->ID, 'product_cat'); if (!is_array($productCategories) || !count($productCategories)) { return $autodetect; } foreach($productCategories as $attribute) { $attributeNameValue = $attribute->name; foreach($womenValues as $womenValue) { if(strpos($attributeNameValue, $womenValue) !== false) { // We do this so we don't match 'male next' $attributeNameValue = str_replace($womenValue,'', $attributeNameValue); $autodetect = 'female'; } } foreach($menValues as $menValue) { if(strpos($attributeNameValue, $menValue) !== false) { $autodetect = 'male'; } } foreach($unisexValues as $unisexValue) { if(strpos($attributeNameValue, $unisexValue) !== false) { $autodetect = 'unisex'; } } } if($autodetect === '') { if($detailedInformationData['genderAutodetect'] == 'setToUnisex') { $autodetect = 'unisex'; } } return $autodetect; } else { throw new \Exception('Unknown vale '.$detailedInformationData['gender'].' for field gender'); } } public function getFieldName() { return 'gender'; } private function getProductCategoryId($product) { $category = $this->getProductCategory($product); return $category->term_id; } private function getProductCategory($product) { $productCategories = get_the_terms($product->ID, 'product_cat'); if (!is_array($productCategories) || !count($productCategories)) { return ''; } // loop through each cat foreach ($productCategories as $category) { // get the children (if any) of the current cat $children = get_categories(array('taxonomy' => 'product_cat', 'parent' => $category->term_id)); if (count($children) == 0) { // if no children, then echo the category name. return $category; } } $lastCategory = $productCategories[0]; return $lastCategory; } /** * @return string * @throws \Exception */ private function getProduct() { if ($this->entry->post_type == 'product') { return $this->entry; } else if ($this->entry->post_type == 'product_variation') { return get_post($this->entry->post_parent); } throw new \Exception('Unknown product type'); } }
[+]
..
[-] Gender.php
[edit]
[-] Material.php
[edit]
[-] CustomLabel4.php
[edit]
[-] Price.php
[edit]
[-] CustomLabel3.php
[edit]
[-] Color.php
[edit]
[-] ExcludedDestination.php
[edit]
[-] Shipping.php
[edit]
[-] CustomLabel2.php
[edit]
[-] Multipack.php
[edit]
[-] AgeGroup.php
[edit]
[-] UnitPricingBaseMeasure.php
[edit]
[-] Adult.php
[edit]
[-] AdditionalImageLink.php
[edit]
[-] Link.php
[edit]
[-] Brand.php
[edit]
[-] ExpirationDate.php
[edit]
[-] Tax.php
[edit]
[-] AvailabilityDate.php
[edit]
[-] Condition.php
[edit]
[-] Mpn.php
[edit]
[-] Gtin.php
[edit]
[-] IsBundle.php
[edit]
[-] SizeType.php
[edit]
[-] Size.php
[edit]
[-] ShippingWeight.php
[edit]
[-] SalePriceEffectiveDate.php
[edit]
[-] ShippingWidth.php
[edit]
[-] CustomLabel1.php
[edit]
[-] Availability.php
[edit]
[-] AdwordsRedirect.php
[edit]
[-] SizeSystem.php
[edit]
[-] ShippingLabel.php
[edit]
[-] FieldFactory.php
[edit]
[-] MobileLink.php
[edit]
[-] GoogleProductCategory.php
[edit]
[-] Id.php
[edit]
[-] ShippingHeight.php
[edit]
[-] EnergyEfficiencyClass.php
[edit]
[-] Pattern.php
[edit]
[-] Description.php
[edit]
[-] UnitPricingMeasure.php
[edit]
[-] ItemGroupId.php
[edit]
[-] ShippingLength.php
[edit]
[-] Field.php
[edit]
[-] ImageLink.php
[edit]
[-] ProductType.php
[edit]
[-] ShippingDimensions.php
[edit]
[-] IdentifierExists.php
[edit]
[-] SalePrice.php
[edit]
[-] PromotionId.php
[edit]
[-] CustomLabel0.php
[edit]
[-] Title.php
[edit]