当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductCategory::getInstance方法代码示例

本文整理汇总了PHP中ProductCategory::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::getInstance方法的具体用法?PHP ProductCategory::getInstance怎么用?PHP ProductCategory::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: OnlineStoreEbay_adminPublish

function OnlineStoreEbay_adminPublish()
{
    list($sess, $vs, $userToken) = OnlineStoreEbay_sessionStart();
    $price = (double) $_REQUEST['buy_now_price'];
    $bidsStartPrice = (double) $_REQUEST['bids_start_at'];
    $countryFrom = $vs['ebay_country_from'];
    $currency = 'EUR';
    $dispatchDays = $vs['ebay_dispatch_days'];
    $productId = (int) $_REQUEST['id'];
    $product = Product::getInstance($productId);
    $description = $product->get('description');
    $paypalAddress = $vs['ebay_paypal_address'];
    $categoryId = 0;
    $rs = ProductsCategoriesProducts::getByProductId($productId);
    foreach ($rs as $r) {
        $c = ProductCategory::getInstance($r);
        if ($c->vals['ebay_id']) {
            $categoryId = $c->vals['ebay_id'];
            break;
        }
    }
    $howMany = (int) $_REQUEST['quantity'];
    $returnsPolicy = $vs['ebay_returns_policy'];
    $title = $product->get('name');
    $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">' . '<ErrorLanguage>en_US</ErrorLanguage><WarningLevel>High</WarningLevel>';
    // { main details
    $xml .= '<Item>' . '<ApplicationData>{"productId":' . $productId . '}</ApplicationData>' . '<Site>Ireland</Site>' . '<Title>' . htmlspecialchars($title) . '</Title>';
    // }
    // { price
    $xml .= '<Currency>' . $currency . '</Currency>';
    if ($bidsStartPrice >= 0.01) {
        $xml .= '<BuyItNowPrice>' . sprintf('%.2f', $price) . '</BuyItNowPrice>' . '<StartPrice>' . sprintf('%.2f', $bidsStartPrice) . '</StartPrice>' . '<ListingType>Chinese</ListingType>';
    } else {
        $xml .= '<StartPrice>' . sprintf('%.2f', $price) . '</StartPrice>' . '<ListingType>FixedPriceItem</ListingType>';
    }
    // }
    // { pictures
    $xml .= '<PictureDetails>';
    $images = $product->getAllImages();
    $siteurl = isset($GLOBALS['DBVARS']['cdn']) && $GLOBALS['DBVARS']['cdn'] ? $GLOBALS['DBVARS']['cdn'] : $_SERVER['HTTP_HOST'];
    $xml .= '<PictureURL>' . str_replace(' ', '%20', 'http://' . $siteurl . '/f' . $product->getDefaultImage()) . '</PictureURL>';
    $images_html = '';
    foreach ($images as $img) {
        $imgUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/f' . $img;
        $xml .= '<PictureURL>' . str_replace(' ', '%20', $imgUrl) . '</PictureURL>';
        $images_html .= '<img src="' . $imgUrl . '"/>';
    }
    $xml .= '</PictureDetails>';
    // }
    // { other main stuff
    $xml .= '<CategoryMappingAllowed>true</CategoryMappingAllowed>' . '<ConditionID>1000</ConditionID>' . '<Country>' . $countryFrom . '</Country>' . '<Location>China</Location>' . '<Description>' . htmlspecialchars($description . $images_html . '<br/><p>' . nl2br($vs['ebay_description_afterword']) . '</p>') . '</Description>' . '<DispatchTimeMax>' . $dispatchDays . '</DispatchTimeMax>' . '<PayPalEmailAddress>' . $paypalAddress . '</PayPalEmailAddress>' . '<ListingDuration>Days_30</ListingDuration>' . '<PaymentMethods>PayPal</PaymentMethods>';
    // }
    $xml .= '<PrimaryCategory><CategoryID>' . $categoryId . '</CategoryID></PrimaryCategory>' . '<Quantity>' . $howMany . '</Quantity>' . '<ReturnPolicy><ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>' . '<ReturnsWithinOption>Days_14</ReturnsWithinOption>' . '<Description>' . htmlspecialchars($returnsPolicy) . '</Description>' . '<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>' . '</ReturnPolicy>' . '<ShippingDetails>' . '<InternationalShippingServiceOption>' . '<ShippingService>IE_SellersStandardRateInternational</ShippingService>' . '<ShippingServiceAdditionalCost currencyID="EUR">0</ShippingServiceAdditionalCost><ShippingServiceCost currencyID="EUR">0</ShippingServiceCost><ShippingServicePriority>0</ShippingServicePriority><ShipToLocation>Europe</ShipToLocation></InternationalShippingServiceOption>' . '<ShippingServiceOptions><FreeShipping>true</FreeShipping>' . '<ShippingService>IE_EconomyDeliveryFromAbroad</ShippingService>' . '<ShippingServiceAdditionalCost currencyID="EUR">0</ShippingServiceAdditionalCost>' . '</ShippingServiceOptions>' . '</ShippingDetails>' . '<ItemSpecifics>' . '<NameValueList><Name>Brand</Name><Value>Generic</Value></NameValueList>' . '<NameValueList><Name>Size</Name><Value>Free Size</Value></NameValueList>' . '</ItemSpecifics>' . '</Item>' . '<RequesterCredentials>' . '<eBayAuthToken>' . $userToken . '</eBayAuthToken>' . '</RequesterCredentials>' . '<WarningLevel>High</WarningLevel>' . '</AddItemRequest>';
    $xmlstr = $sess->sendHttpRequest($xml);
    $reply = new SimpleXMLElement($xmlstr);
    $errors = isset($reply->Errors) ? $reply->Errors : false;
    return array('sent' => $xml, 'reply' => new SimpleXMLElement($xmlstr), 'errors' => $errors);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:58,代码来源:api-admin.php

示例2: Products_adminProductCategoryContainsUpdate

function Products_adminProductCategoryContainsUpdate()
{
    $id = (int) $_REQUEST['id'];
    if (!$id) {
        $id = dbOne('select id from products order by id limit 1', 'id');
    }
    $rs = dbAll('select * from products_categories_products where product_id=' . $id);
    foreach ($rs as $r) {
        $cat = ProductCategory::getInstance($r['category_id']);
        if ($cat) {
            $cat->containsDel($r['product_id'], $r['category_id']);
            $cat->containsAdd($r['product_id'], $r['category_id']);
        } else {
            dbQuery('delete from products_categories_products where product_id=' . $id . ' and category_id=' . $r['category_id']);
        }
    }
    echo $id;
    $id = dbOne('select id from products where id>' . $id . ' order by id limit 1', 'id');
    if ($id) {
        echo '<script>setTimeout(function() {document.location="./id=' . $id . '";}, 1);</script>';
    } else {
        echo '<br/>DONE';
    }
    exit;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:25,代码来源:api-admin.php

示例3: insert

 static function insert($cid, $pid)
 {
     $cid = (int) $cid;
     $pid = (int) $pid;
     $cat = ProductCategory::getInstance($cid);
     if (!$cat) {
         return;
     }
     dbQuery('insert into products_categories_products' . ' set category_id=' . $cid . ', product_id=' . $pid);
     $cat->containsAdd($pid, $cid);
     self::clearCache();
 }
开发者ID:raylouis,项目名称:kvwebme,代码行数:12,代码来源:plugin.php

示例4: render


//.........这里部分代码省略.........
                 }
             }
         } else {
             $tmpprods = $this->product_ids;
         }
         Core_cacheSave('products', $md5, $tmpprods);
     }
     // }
     // { sanitise the limits
     $cnt = count($tmpprods);
     if (!$limit) {
         $limit = $cnt;
         $start = 0;
     } else {
         if ($start && $start >= count($this->product_ids)) {
             $start = $cnt - $limit;
         }
     }
     // }
     // { build array of items
     $prevnext = '';
     $total_found = count($tmpprods);
     if ($cnt == $limit) {
         $prods =& $tmpprods;
     } else {
         $prods = array();
         for ($i = $start; $i < $limit + $start; ++$i) {
             if (isset($tmpprods[$i])) {
                 $prods[] = $tmpprods[$i];
             }
         }
         $prefix = '';
         if ($PAGEDATA->vars['products_what_to_show'] == 2) {
             $cat = ProductCategory::getInstance($PAGEDATA->vars['products_category_to_show']);
             if ($cat) {
                 $prefix = $cat->getRelativeUrl();
             }
         }
         if (!$prefix) {
             $prefix = $PAGEDATA->getRelativeUrl();
         }
         if ($start > $limit_start) {
             $prevnext .= '<a class="products-prev" href="' . $prefix . '?start=' . ($start - $limit) . '">' . __('Previous') . '</a>';
         }
         if ($limit && $start + $limit < $cnt) {
             if ($start) {
                 $prevnext .= ' | ';
             }
             $prevnext .= '<a class="products-next" href="' . $prefix . '?start=' . ($start + $limit) . '">' . __('Next') . '</a>';
         }
     }
     $prevnext = '<div class="products-pagination">' . $prevnext . '</div>';
     // }
     // { see if there are search results
     if (isset($PAGEDATA->vars['products_add_a_search_box']) && $PAGEDATA->vars['products_add_a_search_box']) {
         $c .= '<div class="products-num-results">' . __('<strong>%1</strong> results found.', array($total_found), 'core') . '</div>';
     }
     // }
     if (!isset($PAGEDATA->vars['products_show_multiple_with'])) {
         $PAGEDATA->vars['products_show_multiple_with'] = 0;
     }
     $prods = array_unique($prods);
     switch ($PAGEDATA->vars['products_show_multiple_with']) {
         case 1:
             // { horizontal table, headers on top
             $c .= Product_datatableMultiple($prods, 'horizontal');
开发者ID:raylouis,项目名称:kvwebme,代码行数:67,代码来源:show.php

示例5: Products_typeGet

/**
 * get details about a specific product type
 *
 * @return array the product type details
 */
function Products_typeGet()
{
    $id = (int) @$_REQUEST['id'];
    $r = Core_cacheLoad('products', 'productTypeDetails_' . $id, -1);
    if ($r === -1) {
        $r = dbRow("select * from products_types where id={$id}");
        $r['default_category_name'] = ProductCategory::getInstance($r['default_category'])->vals['name'];
        $r['data_fields'] = json_decode($r['data_fields']);
        Core_cacheSave('products', 'productTypeDetails_' . $id, $r);
    }
    return $r;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:17,代码来源:api.php

示例6: foreach

echo '<select name="widget_type">';
foreach ($types as $t) {
    echo '<option';
    if ($type == $t) {
        echo ' selected="selected"';
    }
    echo '>' . $t . '</option>';
}
echo '</select><br/>';
// }
// { parent category
echo '<strong>Parent Category</strong><br />' . '<select name="parent_cat" id="parent_cat_' . $id . '">';
if (!isset($_REQUEST['parent_cat'])) {
    echo '<option value="0"> -- please choose -- </option>';
} else {
    echo '<option value="' . (int) $_REQUEST['parent_cat'] . '">' . ProductCategory::getInstance((int) $_REQUEST['parent_cat'])->vals['name'] . '</option>';
}
echo '</select><br/>';
// }
// { show products
echo '<div class="show-products"><strong>Show Products</strong><br/>' . '<select name="show_products"><option value="0">No</option>' . '<option value="1"';
if (isset($_REQUEST['show_products']) && $_REQUEST['show_products'] == '1') {
    echo ' selected="selected"';
}
echo '>Yes</select></div>';
// }
// { diameter
echo '<div class="diameter"><strong>Diameter (for Pie Chart)</strong>';
$diameter = isset($_REQUEST['diameter']) && $_REQUEST['diameter'] ? (int) $_REQUEST['diameter'] : 280;
echo '<input name="diameter" value="' . htmlspecialchars($diameter) . '" /></div>';
// }
开发者ID:raylouis,项目名称:kvwebme,代码行数:31,代码来源:widget.php

示例7: join

            }
            echo '<table id="stockcontrol-complex"></table><script>' . 'window.stockcontrol_detail=' . $detail . ';window.stockcontrol_options=["' . join('", "', $options) . '"];</script><a href="#" id="' . 'stockcontrol-addrow">add row</a>' . '<p>' . __('To remove rows, set their options to "-- Choose --" and save the' . ' product.') . '</p>';
        }
        // }
        echo '</div>';
    }
}
// }
Core_trigger('products-show-edit-form-tabs', array($pdata, $product_type));
// { categories
echo '<h2>' . __('Categories') . '</h2><div id="categories"><p>' . __('At least one category must be chosen.') . '</p>';
// { add selected categories to the list
$rs = ProductsCategoriesProducts::getByProductId($id);
echo '<ul id="categories-wrapper">';
foreach ($rs as $r) {
    $cat = ProductCategory::getInstance($r);
    if (!$cat) {
        continue;
    }
    echo '<li><input type="checkbox" name="product_categories[' . $cat->vals['id'] . ']" checked="checked"/>' . $cat->getBreadcrumbs() . '</li>';
}
echo '</ul><button id="category-add">Add Category</button>';
// }
$cid = (int) @$pdata['default_category'];
if (!$cid) {
    $cid = 1;
}
$default_category = Product::getInstance($cid)->vals['name'];
echo '<br/><label>Default Category: <select name="products_default_category">' . '<option value="' . (int) @$pdata['products_default_category'] . '">' . $default_category . '</option></select></label>';
echo '</div>';
// }
开发者ID:raylouis,项目名称:kvwebme,代码行数:31,代码来源:products-edit.php


注:本文中的ProductCategory::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。