Esempio n. 1
0
 function getItem($id)
 {
     global $wpdb;
     $item = $wpdb->get_row($wpdb->prepare("\n\t\t\tSELECT * \n\t\t\tFROM {$this->tablename}\n\t\t\tWHERE profile_id = %s\n\t\t", $id), ARRAY_A);
     $item['details'] = self::decodeObject($item['details'], true);
     $item['conditions'] = unserialize($item['conditions']);
     // get category names
     $item['details']['ebay_category_1_name'] = EbayCategoriesModel::getCategoryName($item['details']['ebay_category_1_id']);
     $item['details']['ebay_category_2_name'] = EbayCategoriesModel::getCategoryName($item['details']['ebay_category_2_id']);
     // make sure that at least one payment and shipping option exist
     $item['details']['loc_shipping_options'] = $this->fixShippingArray($item['details']['loc_shipping_options']);
     $item['details']['int_shipping_options'] = $this->fixShippingArray($item['details']['int_shipping_options']);
     $item['details']['payment_options'] = $this->fixShippingArray($item['details']['payment_options']);
     return $item;
 }
Esempio n. 2
0
 function column_callname($item)
 {
     //Build row action
     $link = sprintf('<a href="?page=%s&action=%s&log_id=%s&width=820&height=550" class="thickbox">%s</a>', $_REQUEST['page'], 'display_log_entry', $item['id'], $item['callname']);
     if ('GeteBayDetails' == $item['callname']) {
         if (preg_match("/<DetailName>(.*)<\\/DetailName>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - ' . strip_tags($match);
         }
     }
     if ('GetOrders' == $item['callname'] || 'GetSellerTransactions' == $item['callname']) {
         if (preg_match("/<PageNumber>(.*)<\\/PageNumber>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - Page ' . strip_tags($match);
         }
         if (preg_match("/<TotalNumberOfPages>(.*)<\\/TotalNumberOfPages>/", $item['response'], $matches)) {
             $link .= ' of ' . strip_tags($matches[1]);
         }
         if (preg_match("/<ModTimeFrom>(.*)<\\/ModTimeFrom>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= '<br>Since: ' . strip_tags($match);
         }
         if (preg_match("/<NumberOfDays>(.*)<\\/NumberOfDays>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= '<br>Days: ' . strip_tags($match);
         }
     }
     if ('GetMyeBaySelling' == $item['callname']) {
         if (preg_match("/<SoldList>(.*)<\\/SoldList>/", $item['request'], $matches)) {
             $link .= ' SoldList ';
         }
         if (preg_match("/<UnsoldList>(.*)<\\/UnsoldList>/", $item['request'], $matches)) {
             $link .= ' UnsoldList ';
         }
         if (preg_match("/<ActiveList>(.*)<\\/ActiveList>/", $item['request'], $matches)) {
             $link .= ' ActiveList ';
         }
         if (preg_match("/<DurationInDays>(.*)<\\/DurationInDays>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' (' . strip_tags($match) . ' days) ';
         }
         if (preg_match("/<PageNumber>(.*)<\\/PageNumber>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - Page ' . strip_tags($match);
         }
     }
     if ('CompleteSale' == $item['callname']) {
         if (preg_match("/<OrderID>(.*)<\\/OrderID>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - ' . strip_tags($match);
         }
     }
     if ('GetCategories' == $item['callname']) {
         if (preg_match("/<CategoryParent>(.*)<\\/CategoryParent>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - ' . strip_tags($match);
         }
     }
     if ('GetNotificationPreferences' == $item['callname']) {
         if (preg_match("/<PreferenceLevel>(.*)<\\/PreferenceLevel>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - ' . strip_tags($match);
         }
     }
     if ('SetNotificationPreferences' == $item['callname']) {
         if (preg_match("/<EventType>(.*)<\\/EventType>/", $item['request'], $matches)) {
             $link .= ' - ' . 'User Events';
         }
     }
     if ('GetMyMessages' == $item['callname']) {
         if (preg_match("/<MessageID>(.*)<\\/MessageID>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' - ' . strip_tags($match);
         }
         if (preg_match("/<DetailLevel>(.*)<\\/DetailLevel>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $link .= ' <span style="color:silver">' . strip_tags($match) . '</span>';
         }
     }
     if (in_array($item['callname'], array('GetCategorySpecifics', 'GetCategoryFeatures'))) {
         if (preg_match("/<CategoryID>(.*)<\\/CategoryID>/", $item['request'], $matches)) {
             $match = str_replace('<![CDATA[', '', $matches[1]);
             $match = str_replace(']]>', '', $match);
             $category_id = strip_tags($match);
             $link .= ' - ' . $category_id;
             $link .= '<br><span style="color: silver; font-size: small;">';
             $link .= EbayCategoriesModel::getFullEbayCategoryName($category_id, $item['site_id']);
             $link .= '</span>';
         }
     }
     if (in_array($item['callname'], array('wplister_revise_inventory_status', 'wplister_revise_item'))) {
         if (is_numeric($item['request'])) {
             $link .= ' - ID: ' . $item['request'];
         }
     }
     // if ( preg_match("/<ShortMessage>(.*)<\/ShortMessage>/", $item['response'], $matches) ) {
     //     $ShortMessage = $matches[1];
     //     if ( $item['success'] == 'Warning' ) {
     //         $link .= '<br><span style="color:darkorange">Warning: '.$ShortMessage.'</span>';
     //     } else {
     //         $link .= '<br><span style="color:#B00">Error: '.$ShortMessage.'</span>';
     //     }
     // }
     $link .= $this->displayErrors($item['errors']);
     $link .= $this->displayExtraMessage($item);
     return $link;
 }
Esempio n. 3
0
 public function ajax_wpl_ebay_store_categories()
 {
     $default_account_id = get_option('wplister_default_account_id');
     $account_id = isset($_REQUEST['account_id']) ? intval($_REQUEST['account_id']) : $default_account_id;
     $store_categories = EbayCategoriesModel::getEntireStoreCategoryTree(0, $account_id);
     // check if callback parameter is set
     if (isset($_REQUEST['callback'])) {
         // return JSONP
         header('content-type: application/javascript; charset=utf-8');
         echo $_REQUEST['callback'] . '(' . json_encode($store_categories) . ')';
     } else {
         // return plain JSON
         header('content-type: application/json; charset=utf-8');
         echo json_encode($store_categories);
     }
     exit;
 }
Esempio n. 4
0
 function printTree($tree, $depth = 0, $result = array())
 {
     $categories_map_ebay = self::getOption('categories_map_ebay');
     $categories_map_store = self::getOption('categories_map_store');
     if ($this->account_id) {
         $categories_map_ebay = maybe_unserialize(WPLE()->accounts[$this->account_id]->categories_map_ebay);
         $categories_map_store = maybe_unserialize(WPLE()->accounts[$this->account_id]->categories_map_store);
     }
     if ($tree != 0 && count($tree) > 0) {
         foreach ($tree as $node) {
             // indent category name accourding to depth
             $node->name = str_repeat('&ndash; ', $depth) . $node->name;
             // echo $node->name;
             // get ebay category and (full) name
             $ebay_category_id = @$categories_map_ebay[$node->term_id];
             $store_category_id = @$categories_map_store[$node->term_id];
             // add item to results - excluding children
             $tmpnode = array('term_id' => $node->term_id, 'parent' => $node->parent, 'category' => $node->name, 'ebay_category_id' => $ebay_category_id, 'ebay_category_name' => EbayCategoriesModel::getFullEbayCategoryName($ebay_category_id, $this->site_id), 'store_category_id' => $store_category_id, 'store_category_name' => EbayCategoriesModel::getFullStoreCategoryName($store_category_id, $this->account_id), 'description' => $node->description);
             $result[] = $tmpnode;
             $result = $this->printTree($node->children, $depth + 1, $result);
         }
     }
     return $result;
 }
Esempio n. 5
0
 private function saveProfile()
 {
     global $wpdb;
     $details = $this->getPreprocessedPostDetails();
     $profile_id = $this->getValueFromPost('profile_id');
     $account_id = $this->getValueFromPost('account_id');
     if (!$account_id) {
         $account_id = get_option('wplister_default_account_id');
     }
     // fix entered prices
     $details = self::fixProfilePrices($details);
     // process item specifics
     $item_specifics = array();
     $itmSpecs_name = @$_POST['itmSpecs_name'];
     $itmSpecs_value = @$_POST['itmSpecs_value'];
     $itmSpecs_attrib = @$_POST['itmSpecs_attrib'];
     if (is_array($itmSpecs_name)) {
         foreach ($itmSpecs_name as $key => $name) {
             #$name = str_replace('\\\\', '', $name );
             $name = stripslashes($name);
             $value = trim($itmSpecs_value[$key]);
             $attribute = trim($itmSpecs_attrib[$key]);
             if ($value != '' || $attribute != '') {
                 $spec = new stdClass();
                 $spec->name = $name;
                 $spec->value = $value;
                 $spec->attribute = $attribute;
                 $item_specifics[] = $spec;
             }
         }
     }
     $details['item_specifics'] = $item_specifics;
     // add category names
     $details['ebay_category_1_name'] = EbayCategoriesModel::getCategoryName($details['ebay_category_1_id']);
     $details['ebay_category_2_name'] = EbayCategoriesModel::getCategoryName($details['ebay_category_2_id']);
     $details['store_category_1_name'] = EbayCategoriesModel::getStoreCategoryName($details['store_category_1_id']);
     $details['store_category_2_name'] = EbayCategoriesModel::getStoreCategoryName($details['store_category_2_id']);
     // fix prices - already done in fixProfilePrices()
     // $details['start_price'] = str_replace(',', '.', $details['start_price'] );
     // $details['fixed_price'] = str_replace(',', '.', $details['fixed_price'] );
     // if the user enters only fixed price but no start price, move fixed price to start price
     if ($details['start_price'] == '' && $details['fixed_price'] != '') {
         $details['start_price'] = $details['fixed_price'];
         $details['fixed_price'] = '';
     }
     // fix quantities
     if (!$details['custom_quantity_enabled']) {
         $details['quantity'] = '';
         $details['max_quantity'] = '';
     }
     // do we have a primary category?
     if (intval($details['ebay_category_1_id']) != 0) {
         $primary_category_id = $details['ebay_category_1_id'];
     } else {
         // if not use default category
         $primary_category_id = self::getOption('default_ebay_category_id');
     }
     // // do we have ConditionDetails for primary category?
     // // $conditions = $this->fetchItemConditions( $primary_category_id, $profile_id, $account_id );
     // $conditions = EbayCategoriesModel::getConditionsForCategory( $primary_category_id, false, $account_id );
     // // do we have item specifics for primary category?
     // if ( intval($profile_id) != 0 ) {
     // 	// $saved_specifics = $wpdb->get_var('SELECT category_specifics FROM '.$wpdb->prefix.'ebay_profiles WHERE profile_id = '.$profile_id);
     // 	$saved_specifics = $wpdb->get_var( $wpdb->prepare( "SELECT category_specifics FROM {$wpdb->prefix}ebay_profiles WHERE profile_id = %d", $profile_id ) );
     // 	$saved_specifics = unserialize($saved_specifics);
     // }
     // // fetch required item specifics for primary category
     // if ( ( isset( $saved_specifics[ $primary_category_id ] ) ) && ( $saved_specifics[ $primary_category_id ] != 'none' ) ) {
     // 	$specifics = $saved_specifics;
     // } elseif ( (int)$primary_category_id != 0 ) {
     // 	$this->initEC( $account_id );
     // 	$specifics = $this->EC->getCategorySpecifics( $primary_category_id );
     // 	$this->EC->closeEbay();
     // } else {
     // 	$specifics = array();
     // }
     // // do we have item specifics for primary category?
     // (improved version of the above, using ebay_categories as cache)
     // $specifics = EbayCategoriesModel::getItemSpecificsForCategory( $primary_category_id, false, $account_id );
     // // $specifics = array( $primary_category_id => $specifics );
     if (WPLISTER_LIGHT) {
         $specifics = array();
     }
     // sql columns
     $item = array();
     $item['profile_id'] = $profile_id;
     $item['profile_name'] = $this->getValueFromPost('profile_name');
     $item['profile_description'] = $this->getValueFromPost('profile_description');
     $item['listing_duration'] = $this->getValueFromPost('listing_duration');
     $item['type'] = $this->getValueFromPost('auction_type');
     $item['sort_order'] = intval($this->getValueFromPost('sort_order'));
     $item['details'] = json_encode($details);
     // $item['conditions']			 		= serialize( $conditions );	// deprecated
     // $item['category_specifics']	 		= serialize( $specifics );	// deprecated
     $item['conditions'] = '';
     $item['category_specifics'] = '';
     $item['account_id'] = $account_id;
     $item['site_id'] = WPLE()->accounts[$item['account_id']]->site_id;
     // insert or update
     if ($item['profile_id'] == 0) {
         // insert new profile
         unset($item['profile_id']);
         $result = $wpdb->insert($wpdb->prefix . 'ebay_profiles', $item);
     } else {
         // update profile
         $result = $wpdb->update($wpdb->prefix . 'ebay_profiles', $item, array('profile_id' => $item['profile_id']));
     }
     // proper error handling
     if ($result === false) {
         $this->showMessage("There was a problem saving your profile.<br>SQL:<pre>" . $wpdb->last_query . '</pre>' . $wpdb->last_error, true);
     } else {
         $this->showMessage(__('Profile saved.', 'wplister'));
         // if we were updating this template as part of setup, move to next step
         if ('4' == self::getOption('setup_next_step')) {
             self::updateOption('setup_next_step', 5);
         }
     }
     // if this is a new profile, skip further processing
     if (!$profile_id) {
         return;
     }
     // handle delayed update option
     if (isset($_POST['wple_delay_profile_application'])) {
         update_option('wple_job_reapply_profile_id', $profile_id);
         return;
     }
     // prepare for updating items
     $listingsModel = new ListingsModel();
     $profilesModel = new ProfilesModel();
     $profile = $profilesModel->getItem($this->getValueFromPost('profile_id'));
     // re-apply profile to all prepared
     if ($this->getValueFromPost('apply_changes_to_all_prepared') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllPreparedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s prepared items updated.', 'wplister'), count($items)));
     }
     // re-apply profile to all verified
     if ($this->getValueFromPost('apply_changes_to_all_verified') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllVerifiedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s verified items updated.', 'wplister'), count($items)));
     }
     // re-apply profile to all published
     if ($this->getValueFromPost('apply_changes_to_all_published') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllPublishedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s published items changed.', 'wplister'), count($items)));
     }
     // re-apply profile to all ended
     if ($this->getValueFromPost('apply_changes_to_all_ended') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllEndedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s ended items updated.', 'wplister'), count($items)));
         // update ended listings - required for autorelist to be applied
         // $listingsModel->updateEndedListings();
         $this->initEC($account_id);
         $this->EC->updateListings();
         $this->EC->closeEbay();
     }
 }
Esempio n. 6
0
echo __('remove', 'wplister');
?>
" class="button btn_remove_ebay_category" onclick="">
								</div>
							</div>
							<div class="clear"></div>

							<?php 
if (@$wpl_default_ebay_category_id && !$item_details['ebay_category_1_id'] && !empty($wpl_item['profile_id'])) {
    ?>
							<div style="position:relative; margin: 5px 10px; clear:both">
								<?php 
    echo __('Conditions and item specifics are based on the category', 'wplister');
    ?>
: <?php 
    echo EbayCategoriesModel::getCategoryName($wpl_default_ebay_category_id);
    ?>
							</div>
							<?php 
}
?>

						</div>
					</div>

					<div class="postbox" id="StoreCategorySelectionBox">
						<h3><span><?php 
echo __('Store categories', 'wplister');
?>
</span></h3>
						<div class="inside">
Esempio n. 7
0
 public function processEbayItemShortcodes($item, $ItemObj, $tpl_html)
 {
     if (!$ItemObj) {
         return $tpl_html;
     }
     // ebay_item_id
     $tpl_html = str_replace('[[ebay_item_id]]', $item['ebay_id'], $tpl_html);
     // ebay_store_category_id
     $tpl_html = str_replace('[[ebay_store_category_id]]', $ItemObj->Storefront->StoreCategoryID, $tpl_html);
     // ebay_store_category_name
     $tpl_html = str_replace('[[ebay_store_category_name]]', EbayCategoriesModel::getStoreCategoryName($ItemObj->Storefront->StoreCategoryID), $tpl_html);
     // ebay_store_url
     // TODO: fetch StoreURL for active account
     $user_details = get_option('wplister_ebay_user');
     if (isset($user_details->StoreURL)) {
         $tpl_html = str_replace('[[ebay_store_url]]', $user_details->StoreURL, $tpl_html);
     }
     return $tpl_html;
 }
Esempio n. 8
0
							</tr>

							<?php 
if ($wpl_item->Storefront->StoreCategoryID) {
    ?>
							<tr>
								<th class="vi-is1-lbl">
									Store Category:
								</th>
								<td colspan="3" class="vi-is1-clr">
									<?php 
    if ($wpl_item->Storefront->StoreCategoryID) {
        echo EbayCategoriesModel::getFullStoreCategoryName($wpl_item->Storefront->StoreCategoryID);
    }
    if ($wpl_item->Storefront->StoreCategory2ID) {
        echo '<br>' . EbayCategoriesModel::getFullStoreCategoryName($wpl_item->Storefront->StoreCategory2ID);
    }
    ?>
								</td>
							</tr>
							<tr>
								<td colspan="4" height="10"></td>
							</tr>
							<?php 
}
?>

						</tbody>
					</table>

Esempio n. 9
0
 public function checkItem($item, $reviseItem = false)
 {
     $success = true;
     $this->VariationsHaveStock = false;
     // check StartPrice, Quantity and SKU
     if (is_object($item->Variations)) {
         // item has variations
         $VariationsHaveStock = false;
         $VariationsSkuArray = array();
         $VariationsSkuAreUnique = true;
         $VariationsSkuMissing = false;
         // check each variation
         foreach ($item->Variations->Variation as $var) {
             // StartPrice must be greater than 0
             if (self::dbSafeFloatval($var->StartPrice) == 0) {
                 $longMessage = __('Some variations seem to have no price.', 'wplister');
                 $success = false;
             }
             // Quantity must be greater than 0 - at least for one variation
             if (intval($var->Quantity) > 0) {
                 $VariationsHaveStock = true;
             }
             // SKUs must be unique - if present
             if ($var->SKU != '') {
                 if (in_array($var->SKU, $VariationsSkuArray)) {
                     $VariationsSkuAreUnique = false;
                 } else {
                     $VariationsSkuArray[] = $var->SKU;
                 }
             } else {
                 $VariationsSkuMissing = true;
             }
             // VariationSpecifics values can't be longer than 50 characters
             foreach ($var->VariationSpecifics->NameValueList as $spec) {
                 if (strlen($spec->Value) > 50) {
                     $longMessage = __('eBay does not allow attribute values longer than 50 characters.', 'wplister');
                     $longMessage .= '<br>';
                     $longMessage .= __('You need to shorten this value:', 'wplister') . ' <code>' . $spec->Value . '</code>';
                     $success = false;
                 }
             }
         }
         if (!$VariationsSkuAreUnique) {
             foreach ($item->Variations->Variation as &$var) {
                 $var->SKU = '';
             }
             $longMessage = __('You are using the same SKU for more than one variations which is not allowed by eBay.', 'wplister');
             $longMessage .= '<br>';
             $longMessage .= __('To circumvent this issue, your item will be listed without SKU.', 'wplister');
             // $success = false;
         }
         if ($VariationsSkuMissing) {
             $longMessage = __('Some variations are missing a SKU.', 'wplister');
             $longMessage .= '<br>';
             $longMessage .= __('It is required to assign a unique SKU to each variation to prevent issues syncing sales.', 'wplister');
             // $success = false;
         }
         if (!$VariationsHaveStock && !$reviseItem && !ListingsModel::thisAccountUsesOutOfStockControl($this->account_id)) {
             $longMessage = __('None of these variations are in stock.', 'wplister');
             $success = false;
         }
         // make this info available to reviseItem()
         $this->VariationsHaveStock = $VariationsHaveStock;
     } else {
         // item has no variations
         // StartPrice must be greater than 0
         if (self::dbSafeFloatval($item->StartPrice->value) == 0) {
             $longMessage = __('Price can not be zero.', 'wplister');
             $success = false;
         }
         // check minimum start price if found
         // $min_prices = get_option( 'wplister_MinListingStartPrices', array() );
         $min_prices = $this->site_id ? maybe_unserialize(WPLE_eBaySite::getSiteObj($this->site_id)->MinListingStartPrices) : array();
         if (!is_array($min_prices)) {
             $min_prices = array();
         }
         $listing_type = $item->ListingType ? $item->ListingType : 'FixedPriceItem';
         if (isset($min_prices[$listing_type])) {
             $min_price = $min_prices[$listing_type];
             if ($item->StartPrice->value < $min_price) {
                 $longMessage = sprintf(__('eBay requires a minimum price of %s for this listing type.', 'wplister'), $min_price);
                 $success = false;
             }
         }
     }
     // check if any required item specifics are missing
     $primary_category_id = $item->PrimaryCategory->CategoryID;
     $specifics = EbayCategoriesModel::getItemSpecificsForCategory($primary_category_id, $this->site_id, $this->account_id);
     foreach ($specifics as $req_spec) {
         // skip non-required specs
         if (!$req_spec->MinValues) {
             continue;
         }
         // skip if Name already exists in ItemSpecifics
         if (self::thisNameExistsInNameValueList($req_spec->Name, $item->ItemSpecifics->NameValueList)) {
             continue;
         }
         // skip if Name already exists in VariationSpecificsSet
         if (is_object($item->Variations)) {
             $VariationSpecificsSet = $item->Variations->getVariationSpecificsSet();
             if (self::thisNameExistsInNameValueList($req_spec->Name, $VariationSpecificsSet->NameValueList)) {
                 continue;
             }
         }
         $DoesNotApplyText = WPLE_eBaySite::getSiteObj($this->site_id)->DoesNotApplyText;
         $DoesNotApplyText = empty($DoesNotApplyText) ? 'Does not apply' : $DoesNotApplyText;
         // // add missing item specifics
         $NameValueList = new NameValueListType();
         $NameValueList->setName($req_spec->Name);
         $NameValueList->setValue($DoesNotApplyText);
         $item->ItemSpecifics->addNameValueList($NameValueList);
         wple_show_message('<b>Note:</b> Missing item specifics <b>' . $req_spec->Name . '</b> was set to "' . $DoesNotApplyText . '" in order to prevent listing errors.', 'warn');
     }
     // check if any item specific have more values than allowed
     foreach ($specifics as $req_spec) {
         // skip specs without limit
         if (!$req_spec->MaxValues) {
             continue;
         }
         // count values for this item specific
         $number_of_values = self::countValuesForNameInNameValueList($req_spec->Name, $item->ItemSpecifics->NameValueList);
         if ($number_of_values <= $req_spec->MaxValues) {
             continue;
         }
         // remove additional values from item specific
         for ($i = 0; $i < sizeof($item->ItemSpecifics->NameValueList); $i++) {
             if ($item->ItemSpecifics->NameValueList[$i]->Name != $req_spec->Name) {
                 continue;
             }
             $values_array = $item->ItemSpecifics->NameValueList[$i]->Value;
             $item->ItemSpecifics->NameValueList[$i]->Value = reset($values_array);
         }
         wple_show_message('<b>Note:</b> The item specifics <b>' . $req_spec->Name . '</b> has ' . $number_of_values . ' values, but eBay allows only ' . $req_spec->MaxValues . ' value(s).<br>In order to prevent listing errors, additional values will be omitted.', 'warn');
     }
     // ItemSpecifics values can't be longer than 50 characters
     foreach ($item->ItemSpecifics->NameValueList as $spec) {
         $values = is_array($spec->Value) ? $spec->Value : array($spec->Value);
         foreach ($values as $value) {
             if (strlen($value) > 50) {
                 $longMessage = __('eBay does not allow attribute values longer than 50 characters.', 'wplister');
                 $longMessage .= '<br>';
                 $longMessage .= __('You need to shorten this value:', 'wplister') . ' <code>' . $value . '</code>';
                 $success = false;
             }
         }
     }
     // PrimaryCategory->CategoryID must be greater than 0
     if (intval(@$item->PrimaryCategory->CategoryID) == 0) {
         $longMessage = __('There has been no primary category assigned.', 'wplister');
         $success = false;
     }
     // check for main image
     if (trim(@$item->PictureDetails->GalleryURL) == '') {
         $longMessage = __('You need to add at least one image to your product.', 'wplister');
         $success = false;
     }
     // remove ReservedPrice on fixed price items
     if ($item->getReservePrice() && $item->getListingType() == 'FixedPriceItem') {
         $item->setReservePrice(null);
         $longMessage = __('Reserve price does not apply to fixed price listings.', 'wplister');
         // $success = false;
     }
     // omit price and shipping cost when revising an item with promotional sale enabled
     if ($reviseItem && ListingsModel::thisListingHasPromotionalSale($this->listing_id)) {
         $item->setStartPrice(null);
         $item->setShippingDetails(null);
         wple_show_message(__('Price and shipping were omitted since this item has promotional sale enabled.', 'wplister'), 'info');
     }
     if (!$success && !$this->is_ajax()) {
         wple_show_message($longMessage, 'error');
     } elseif ($longMessage != '' && !$this->is_ajax()) {
         wple_show_message($longMessage, 'warn');
     }
     $htmlMsg = '<div id="message" class="error" style="display:block !important;"><p>';
     $htmlMsg .= '<b>' . 'This item did not pass the validation check' . ':</b>';
     $htmlMsg .= '<br>' . $longMessage . '';
     $htmlMsg .= '</p></div>';
     // save error as array of objects
     $errorObj = new stdClass();
     $errorObj->SeverityCode = 'Validation';
     $errorObj->ErrorCode = '42';
     $errorObj->ShortMessage = $longMessage;
     $errorObj->LongMessage = $longMessage;
     $errorObj->HtmlMessage = $htmlMsg;
     $errors = array($errorObj);
     // save results as local property
     $this->result = new stdClass();
     $this->result->success = $success;
     $this->result->errors = $errors;
     return $success;
 }
Esempio n. 10
0
 function showItemSpecifics()
 {
     global $post;
     // get data
     $wpl_available_attributes = ProductWrapper::getAttributeTaxonomies();
     $wpl_default_ebay_category_id = get_post_meta($post->ID, '_ebay_category_1_id', true);
     // $specifics contains all available item specifics for the selected category
     // $item_specifics contains values set for this particular product / profile
     // $specifics                 = get_post_meta( $post->ID, '_ebay_category_specifics', true );
     $specifics = array();
     $item_specifics = get_post_meta($post->ID, '_ebay_item_specifics', true);
     // get listing object
     $listing = $this->get_current_ebay_item();
     $wpl_account_id = $listing && $listing->account_id ? $listing->account_id : get_option('wplister_default_account_id');
     $wpl_site_id = $listing ? $listing->site_id : get_option('wplister_ebay_site_id');
     // $profile_id  = $listing && $listing->profile_id ? $listing->profile_id : false;
     $post_id = $post->ID;
     // // if primary category is set on product level, update stored category specifics if required
     // // (fixes empty item specifics box on imported products)
     // if ( $wpl_default_ebay_category_id && ! $specifics ) {
     // 	$specifics = $this->get_updated_item_specifics_for_product_and_category( $post_id, $wpl_default_ebay_category_id, $wpl_account_id );
     // }
     // if no primary category selected on product level, check profile for primary category
     $profile = $this->get_current_listing_profile();
     if (!$wpl_default_ebay_category_id) {
         if ($profile && $profile['details']['ebay_category_1_id']) {
             $wpl_default_ebay_category_id = $profile['details']['ebay_category_1_id'];
             // $specifics = maybe_unserialize( $profile['category_specifics'] );
         }
     }
     // if there is still no primary eBay category, look up the product's category in the category map
     if (!$wpl_default_ebay_category_id) {
         // get ebay categories map
         $categories_map_ebay = get_option('wplister_categories_map_ebay');
         if (isset(WPLE()->accounts[$wpl_account_id])) {
             $account = WPLE()->accounts[$wpl_account_id];
             $categories_map_ebay = maybe_unserialize($account->categories_map_ebay);
         }
         // fetch products local category terms
         $terms = wp_get_post_terms($post_id, ProductWrapper::getTaxonomy());
         // WPLE()->logger->info('terms: '.print_r($terms,1));
         // echo "<pre>";print_r($terms);echo"</pre>";#die();
         // echo "<pre>";print_r($categories_map_ebay);echo"</pre>";#die();
         $ebay_category_id = false;
         foreach ($terms as $term) {
             // look up ebay category
             if (isset($categories_map_ebay[$term->term_id])) {
                 $ebay_category_id = $categories_map_ebay[$term->term_id];
                 $ebay_category_id = apply_filters('wplister_apply_ebay_category_map', $ebay_category_id, $post_id);
             }
             // check ebay category
             if (intval($ebay_category_id) > 0) {
                 $wpl_default_ebay_category_id = $ebay_category_id;
                 // $specifics = $this->get_updated_item_specifics_for_product_and_category( $post_id, $ebay_category_id, $wpl_account_id );
                 break;
             }
         }
         // each term
     }
     // if still no ebay category
     // load specifics if we have a category
     if ($wpl_default_ebay_category_id) {
         $specifics = EbayCategoriesModel::getItemSpecificsForCategory($wpl_default_ebay_category_id, false, $wpl_account_id);
         // $specifics = array( $wpl_default_ebay_category_id => $specifics );
     }
     // echo "<pre>";print_r($wpl_default_ebay_category_id);echo"</pre>";#die();
     // echo "<pre>";print_r($profile);echo"</pre>";#die();
     // echo "<pre>";print_r($specifics);echo"</pre>";#die();
     // echo "<pre>";print_r($item_specifics);echo"</pre>";#die();
     // add attribute for SKU
     // $attrib = new stdClass();
     // $attrib->name = '_sku';
     // $attrib->label = 'SKU';
     // $wpl_available_attributes[] = $attrib;
     // process custom attributes
     $wpl_custom_attributes = array();
     $custom_attributes = apply_filters('wplister_custom_attributes', array());
     if (is_array($custom_attributes)) {
         foreach ($custom_attributes as $attrib) {
             $new_attribute = new stdClass();
             $new_attribute->name = $attrib['id'];
             $new_attribute->label = $attrib['label'];
             $wpl_custom_attributes[] = $new_attribute;
         }
     }
     echo '<div class="ebay_item_specifics_wrapper">';
     echo '<h2>' . __('Item Specifics', 'wplister') . '</h2>';
     include WPLISTER_PATH . '/views/profile/edit_item_specifics.php';
     // let the user know which category the available item specifics are based on
     if ($profile && $profile['details']['ebay_category_1_id']) {
         $profile_link = '<a href="admin.php?page=wplister-profiles&action=edit&profile=' . $profile['profile_id'] . '" target="_blank">' . $profile['profile_name'] . '</a>';
         echo '<small>These options are based on the selected profile <b>' . $profile_link . '</b> and its primary eBay category <b>' . $profile['details']['ebay_category_1_name'] . '</b>.</small>';
     } elseif ($wpl_default_ebay_category_id && isset($categories_map_ebay)) {
         $category_path = EbayCategoriesModel::getFullEbayCategoryName($wpl_default_ebay_category_id, $wpl_site_id);
         echo '<small>Item specifics are based on the eBay category <b>' . $category_path . '</b> according to your category settings.</small>';
     }
     echo '</div>';
 }
Esempio n. 11
0
 public function getCategorySpecifics($category_id, $site_id = false)
 {
     if (!$site_id) {
         $site_id = $this->siteId;
     }
     $cm = new EbayCategoriesModel();
     // always update conditions before specifics
     $conditions = $cm->fetchCategoryConditions($this->session, $category_id, $site_id);
     $specifics = $cm->fetchCategorySpecifics($this->session, $category_id, $site_id);
     return $specifics;
 }