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


PHP Price::load_download方法代码示例

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


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

示例1: substr


//.........这里部分代码省略.........

				foreach($deletes as $option) {
					$Price = new Price($option);
					$Price->delete();
				}
			}

			// Save prices that there are updates for
			foreach($_POST['price'] as $i => $option) {
				if (empty($option['id'])) {
					$Price = new Price();
					$option['product'] = $Product->id;
				} else $Price = new Price($option['id']);
				$option['sortorder'] = array_search($i,$_POST['sortorder'])+1;

				// Remove VAT amount to save in DB
				if ($base['vat'] && isset($option['tax']) && $option['tax'] == "on") {
					$option['price'] = (floatvalue($option['price'])/(1+$taxrate));
					$option['saleprice'] = (floatvalue($option['saleprice'])/(1+$taxrate));
				}
				$option['shipfee'] = floatvalue($option['shipfee']);

				$option['weight'] = floatvalue($option['weight']);
				if (isset($options['dimensions']) && is_array($options['dimensions']))
					foreach ($option['dimensions'] as &$dimension)
						$dimension = floatvalue($dimension);

				$Price->updates($option);
				$Price->save();

				if (!empty($option['download'])) $Price->attach_download($option['download']);

				if (!empty($option['downloadpath'])) { // Attach file specified by URI/path
					if (!empty($Price->download->id) || (empty($Price->download) && $Price->load_download())) {
						$File = $Price->download;
					} else $File = new ProductDownload();

					$stored = false;
					$tmpfile = sanitize_path($option['downloadpath']);

					$File->storage = false;
					$Engine = $File->_engine(); // Set engine from storage settings

					$File->parent = $Price->id;
					$File->context = "price";
					$File->type = "download";
					$File->name = !empty($option['downloadfile'])?$option['downloadfile']:basename($tmpfile);
					$File->filename = $File->name;

					if ($File->found($tmpfile)) {
						$File->uri = $tmpfile;
						$stored = true;
					} else $stored = $File->store($tmpfile,'file');

					if ($stored) {
						$File->readmeta();
						$File->save();
					}

				} // END attach file by path/uri
			}
			unset($Price);
		}

		// No variation options at all, delete all variation-pricelines
		if (!empty($Product->prices) && is_array($Product->prices)
开发者ID:robbiespire,项目名称:paQui,代码行数:67,代码来源:Warehouse.php

示例2: shopp_product_variant

/**
 * Get a specific Price object
 *
 * @api
 * @since 1.2
 *
 * @param mixed $variant the id of the variant, or array('product'=>int, 'option' => array('menu1name'=>'option', 'menu2name'=>'option') ) to specify variant by product id and option
 * @param string $pricetype (optional default:variant) product, variant, or addon
 * @return ShoppPrice Price object or false on error
 **/
function shopp_product_variant($variant = false, $pricetype = 'variant')
{
    if (false === $variant) {
        shopp_debug(__FUNCTION__ . " failed: Variant id required.");
        return false;
    }
    if (is_numeric($variant)) {
        $Price = new ShoppPrice($variant);
        if (empty($Price->id)) {
            shopp_debug(__FUNCTION__ . " failed: Unable to load variant {$variant}.");
            return false;
        }
    } else {
        if (is_array($variant)) {
            // specifying variant by product id and option
            $Product = new stdClass();
            if (isset($variant['product']) && is_numeric($variant['product'])) {
                $Product = new ShoppProduct($variant['product']);
                $Product->load_data(array('prices', 'meta', 'summary'));
            }
            if (empty($Product->id) || empty($Product->prices)) {
                shopp_debug(__FUNCTION__ . " failed: Unable to load variant.  Invalid Product.");
                return false;
            }
            $pricetype = $pricetype == 'variant' ? 'variation' : $pricetype;
            $pricetypes = array('product', 'variation', 'addon');
            if (!in_array($pricetype, $pricetypes)) {
                shopp_debug(__FUNCTION__ . " failed: Invalid pricetype.  Can be product, variant, or addon.");
                return false;
            }
            if ('product' == $pricetype) {
                // No product context for product with variants
                if ('on' == $Product->variants) {
                    shopp_debug(__FUNCTION__ . " failed: Invalid pricetype for this product.");
                    return false;
                }
                foreach ($Product->prices as $price) {
                    if ('product' == $price->context) {
                        $Price = new ShoppPrice();
                        $Price->populate($price);
                        $Price->load_settings();
                        $Price->load_download();
                        break;
                    }
                }
            } else {
                // addon or variant
                if (!isset($variant['option']) || !is_array($variant['option']) || empty($variant['option'])) {
                    shopp_debug(__FUNCTION__ . " failed: Missing option array.");
                    return false;
                }
                $menukey = substr($pricetype, 0, 1);
                $flag = $pricetype == 'variation' ? 'variants' : 'addons';
                if (!isset($Product->options[$menukey]) || $Product->{$flag} == 'off') {
                    shopp_debug(__FUNCTION__ . " failed: No product variant options of type {$pricetype} for product {$Product->id}");
                    return false;
                }
                // build simple option menu array
                $menu = array();
                foreach ($Product->options[$menukey] as $optionmenu) {
                    $key = $optionmenu['name'];
                    $menu[$key] = array();
                    foreach ($optionmenu['options'] as $option) {
                        $menu[$key][] = $option['name'];
                    }
                }
                list($optionkey, $options, $label, $mapping) = $Product->optionmap($variant['option'], $menu, $pricetype);
                if ('variation' == $pricetype && !isset($Product->pricekey[$optionkey]) || !$options) {
                    shopp_debug(__FUNCTION__ . " failed: Invalid option.");
                    return false;
                }
                if ('variation' == $pricetype) {
                    $price = $Product->pricekey[$optionkey];
                } else {
                    // Find the option
                    foreach ($Product->prices as $price) {
                        if ($price->context == $pricetype && $price->options == $options) {
                            break;
                        }
                    }
                }
                $Price = new Price();
                $Price->populate($price);
                $Price->load_settings();
                $Price->load_download();
            }
            // end if product type / addon/variants type
        }
    }
    if (!isset($Price)) {
//.........这里部分代码省略.........
开发者ID:forthrobot,项目名称:inuvik,代码行数:101,代码来源:product.php


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