Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 function column_weight($item)
 {
     return ProductWrapper::getWeight($item['post_id']);
 }
Esempio n. 3
0
 public function getDynamicShipping($price, $post_id)
 {
     // return price if no mapping
     if (!substr($price, 0, 1) == '[') {
         return self::dbSafeFloatval($price);
     }
     // split values list
     $values = substr($price, 1, -1);
     $values = explode('|', $values);
     // first item is mode
     $mode = array_shift($values);
     // weight mode
     if ($mode == 'weight') {
         $product_weight = ProductWrapper::getWeight($post_id);
         foreach ($values as $val) {
             list($limit, $price) = explode(':', $val);
             if ($product_weight >= $limit) {
                 $shipping_cost = $price;
             }
         }
         return self::dbSafeFloatval($shipping_cost);
     }
     // convert '0.00' to '0' - ebay api doesn't like '0.00'
     if ($price == 0) {
         $price = '0';
     }
     return self::dbSafeFloatval($price);
 }