public function previewListing($id) { // init model $ibm = new ItemBuilderModel(); $account_id = WPLE_ListingQueryHelper::getAccountID($id); $account = WPLE_eBayAccount::getAccount($account_id); $this->initEC($account_id); $item = $ibm->buildItem($id, $this->EC->session, false, true); // if ( ! $ibm->checkItem($item) ) return $ibm->result; $ibm->checkItem($item); // $preview_html = $ibm->getFinalHTML( $id, $item, true ); $preview_html = $item->Description; // echo $preview_html; // set condition name $item->ConditionName = $this->getConditionDisplayName($item->getConditionID()); $aData = array('item' => $item, 'site_id' => $account ? $account->site_id : false, 'check_result' => $ibm->result, 'preview_html' => $preview_html); header('Content-Type: text/html; charset=utf-8'); $this->display('listings_preview', $aData); exit; }
public function processItem($item, $ItemObj = false, $preview = false) { $ibm = new ItemBuilderModel(); // let other plugin know we are doing an eBay listing if (!defined('WPL_EBAY_LISTING')) { define('WPL_EBAY_LISTING', true); } // let other plugin know we are doing an eBay listing if ($preview && !defined('WPL_EBAY_PREVIEW')) { define('WPL_EBAY_PREVIEW', true); } // load template content $this->initTemplate($preview); $tpl_html = $this->getContent(); // handle errors if (!$tpl_html) { WPLE()->logger->error('template not found ' . $item['template']); WPLE()->logger->error('should be here: ' . WP_CONTENT_DIR . '/uploads/wp-lister/templates/' . $item['template']); $this->showMessage('There was a problem processing your listing template', 1, 1); return ''; // echo 'Template not found: '.$item['template']; // die(); } // WPLE()->logger->debug( 'template loaded from ' . $tpl_path ); // WPLE()->logger->info( $tpl_html ); // TODO: check if $item['post_id'] point to a valid product. Could have been deleted... // custom template hook $tpl_html = apply_filters('wplister_before_process_template_html', $tpl_html, $item); // replace shortcodes $tpl_html = str_replace('[[product_title]]', $ibm->prepareTitleAsHTML($item['auction_title']), $tpl_html); // process simple text shortcodes (used for title as well) $tpl_html = $this->processAllTextShortcodes($item['post_id'], $tpl_html, false, $ItemObj); // process custom fields $tpl_html = $this->processCustomFields($tpl_html); // process embedded code $tpl_html = $this->processEmbeddedCode($tpl_html); // process ajax galleries $tpl_html = $this->processGalleryShortcodes($item['id'], $tpl_html); // process item shortcodes $tpl_html = $this->processEbayItemShortcodes($item, $ItemObj, $tpl_html); // handle images... $main_image = $ibm->getProductMainImageURL($item['post_id']); $images = $ibm->getProductImagesURL($item['post_id']); WPLE()->logger->debug('images found ' . print_r($images, 1)); // [[product_main_image]] $the_main_image = '<img class="wpl_product_image" src="' . $main_image . '" alt="main product image" />'; $tpl_html = str_replace('[[product_main_image]]', $the_main_image, $tpl_html); // [[product_main_image_url]] $tpl_html = str_replace('[[product_main_image_url]]', $main_image, $tpl_html); // handle [[add_img_1]] to [[add_img_12]] // and [[add_img_url_1]] to [[add_img_url_12]] for ($i = 0; $i < 12; $i++) { if (isset($images[$i])) { $img_url = $images[$i]; $img_tag = '<img class="wpl_additional_product_image img_' . ($i + 1) . '" src="' . $img_url . '" />'; } else { $img_url = ''; $img_tag = ''; } $tpl_html = str_replace('[[img_' . ($i + 1) . ']]', $img_tag, $tpl_html); $tpl_html = str_replace('[[img_url_' . ($i + 1) . ']]', $img_url, $tpl_html); } // handle all additional images // [[additional_product_images]] $imagelist = $this->processThumbnailsShortcode($images, $item); $tpl_html = str_replace('[[additional_product_images]]', $imagelist, $tpl_html); // process wp shortcodes in listing template - if enabled if ('full' == get_option('wplister_process_shortcodes', 'content')) { $tpl_html = do_shortcode($tpl_html); } // custom template hook $tpl_html = apply_filters('wplister_process_template_html', $tpl_html, $item, $images); // return html return $tpl_html; }
public function previewTemplate($template_id, $listing_id = false) { // init model $ibm = new ItemBuilderModel(); $preview_html = $ibm->getPreviewHTML($template_id, $listing_id); echo $preview_html; exit; }
function verifyAddItem($id, $session) { // skip this item if item status not allowed $allowed_statuses = array('prepared', 'verified'); if (!$this->itemHasAllowedStatus($id, $allowed_statuses)) { return $this->result; } // build item $ibm = new ItemBuilderModel(); $item = $ibm->buildItem($id, $session); if (!$ibm->checkItem($item)) { return $ibm->result; } // eBay Motors (beta) if ($item->Site == 'eBayMotors') { $session->setSiteId(100); } // preparation - set up new ServiceProxy with given session $this->initServiceProxy($session); // switch to FixedPriceItem if product has variations $listing_item = self::getItem($id); // $useFixedPriceItem = ( ProductWrapper::hasVariations( $listing_item['post_id'] ) ) ? true : false; // $useFixedPriceItem = ( 'FixedPriceItem' == $listing_item['auction_type'] ) ? true : false; WPLE()->logger->info("Verifying #{$id}: " . $item->Title); if (self::listingUsesFixedPriceItem($listing_item)) { $req = new VerifyAddFixedPriceItemRequestType(); $req->setItem($item); WPLE()->logger->debug("Request: " . print_r($req, 1)); $res = $this->_cs->VerifyAddFixedPriceItem($req); } else { $req = new VerifyAddItemRequestType(); $req->setItem($item); WPLE()->logger->debug("Request: " . print_r($req, 1)); $res = $this->_cs->VerifyAddItem($req); } // handle response and check if successful if ($this->handleResponse($res)) { // save listing fees to db $listingFee = self::getListingFeeFromResponse($res); // $data['ebay_id'] = $res->ItemID; $data['fees'] = $listingFee; $data['status'] = 'verified'; self::updateListing($id, $data); WPLE()->logger->info("Item #{$id} verified with ebay, getAck(): " . $res->getAck()); } // call successful self::processErrorsAndWarnings($id, $this->result); return $this->result; }
public function previewListing($id) { // init model $ibm = new ItemBuilderModel(); $preview_html = $ibm->getFinalHTML($id); echo $preview_html; exit; }