public function processAllTextShortcodes($post_id, $tpl_html, $max_length = false, $ItemObj = false) { // get item object $listing_id = WPLE_ListingQueryHelper::getListingIDFromPostID($post_id); $item = ListingsModel::getItem($listing_id); // main content - [[product_content]] (unless updating title when saving product...) if (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'editpost' || isset($_REQUEST['wpl_ebay_revise_on_update']) || isset($_REQUEST['wpl_ebay_relist_on_update'])) { $tpl_html = $this->processMainContentShortcode($post_id, $tpl_html, $item); } // product excerpt $product_id = $item['parent_id'] ? $item['parent_id'] : $item['post_id']; // maybe use parent post_id (for split variations) $tpl_html = str_replace('[[product_excerpt]]', WPLE_ListingQueryHelper::getRawPostExcerpt($product_id), $tpl_html); $tpl_html = str_replace('[[product_excerpt_nl2br]]', nl2br(WPLE_ListingQueryHelper::getRawPostExcerpt($product_id)), $tpl_html); $tpl_html = str_replace('[[product_additional_content]]', wpautop(WPLE_ListingQueryHelper::getRawPostExcerpt($product_id)), $tpl_html); $tpl_html = str_replace('[[product_additional_content_nl2br]]', nl2br(WPLE_ListingQueryHelper::getRawPostExcerpt($product_id)), $tpl_html); // product price $item_price = $item['price']; if ($ItemObj && $ItemObj->StartPrice) { $item_price = $ItemObj->StartPrice->value; } if ($ItemObj && $ItemObj->Variations) { $item_price = $ItemObj->Variations->Variation[0]->StartPrice; } $tpl_html = str_replace('[[product_price]]', number_format_i18n(floatval($item_price), 2), $tpl_html); $tpl_html = str_replace('[[product_price_raw]]', $item_price, $tpl_html); // product_category $tpl_html = str_replace('[[product_category]]', ProductWrapper::getProductCategoryName($post_id), $tpl_html); // SKU $tpl_html = str_replace('[[product_sku]]', ProductWrapper::getSKU($post_id), $tpl_html); // weight $tpl_html = str_replace('[[product_weight]]', ProductWrapper::getWeight($post_id, true), $tpl_html); // dimensions $dimensions = ProductWrapper::getDimensions($post_id); $width = @$dimensions['width'] . ' ' . @$dimensions['width_unit']; $height = @$dimensions['height'] . ' ' . @$dimensions['height_unit']; $length = @$dimensions['length'] . ' ' . @$dimensions['length_unit']; $tpl_html = str_replace('[[product_width]]', $width, $tpl_html); $tpl_html = str_replace('[[product_height]]', $height, $tpl_html); $tpl_html = str_replace('[[product_length]]', $length, $tpl_html); // attributes $tpl_html = $this->processAttributeShortcodes($post_id, $tpl_html, $max_length); // custom meta $tpl_html = $this->processCustomMetaShortcodes($post_id, $tpl_html, $max_length); return $tpl_html; }
public function buildProductOptions($id, $item, $post_id, $profile_details, $listing, $hasVariations, $isVariation) { // get product SKU $product_sku = ProductWrapper::getSKU($post_id); // if this is a single split variation, use variation SKU instead of parent SKU if ($isVariation) { $product_sku = ProductWrapper::getSKU($listing['post_id']); } // set SKU - if not empty if (trim($product_sku) == '') { $product_sku = false; } if ($product_sku) { $item->SKU = $product_sku; } // build buildProductListingDetails (UPC, EAN, MPN, etc.) $item = $this->buildProductListingDetails($id, $item, $post_id, $profile_details, $listing, $hasVariations, $isVariation, $product_sku); // add subtitle if enabled if (@$profile_details['subtitle_enabled'] == 1) { // check if custom post meta field '_ebay_subtitle' exists if (get_post_meta($post_id, '_ebay_subtitle', true)) { $subtitle = get_post_meta($post_id, '_ebay_subtitle', true); } elseif (get_post_meta($post_id, 'ebay_subtitle', true)) { $subtitle = get_post_meta($post_id, 'ebay_subtitle', true); } else { // check for custom subtitle from profile $subtitle = @$profile_details['custom_subtitle']; } // if empty use product excerpt if ($subtitle == '') { $the_post = get_post($post_id); $subtitle = strip_tags($the_post->post_excerpt); } // limit to 55 chars to avoid error $subtitle = substr($subtitle, 0, 55); $item->setSubTitle($subtitle); WPLE()->logger->debug('setSubTitle: ' . $subtitle); } // item condition description $condition_description = false; if (@$profile_details['condition_description'] != '') { $condition_description = $profile_details['condition_description']; $templatesModel = new TemplatesModel(); $condition_description = $templatesModel->processAllTextShortcodes($post_id, $condition_description); $item->setConditionDescription($condition_description); } return $item; }