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


PHP WishList::addProduct方法代码示例

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


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

示例1: findProductByName

    {
        return $this->items;
    }
    public function findProductByName($name)
    {
        $itemKey = null;
        foreach ($this->items as $key => $item) {
            if ($name == $item->getName()) {
                $itemKey = $key + 1;
                echo "{$name} is number {$itemKey} in the array";
                break;
            }
        }
        if ($itemKey == null) {
            throw new Exception("Item was not found in cart");
        }
    }
}
$describer = new ItemDescriber();
$kramericaTV = new Television("Giant TV", "Kramerica", 3900.9, "LED", "100in");
$shirt = new Clothing("Button Down Shirt", "J Peterman", '29.88', "shirt", "medium", "red", "male");
$Wishlist = new WishList();
$Wishlist->addProduct($kramericaTV);
$Wishlist->addProduct($shirt);
$ShoppingCart = $Wishlist->createCartFromContainer($Wishlist);
$Wishlist->provideDescription();
$ShoppingCart->provideDescription();
?>
    </p>
  </body>
</html>
开发者ID:jacobfoard,项目名称:Curriculum,代码行数:31,代码来源:02_hard.php

示例2: WishList

        if (!isset($context->cookie->id_wishlist) || $context->cookie->id_wishlist == '') {
            $wishlist = new WishList();
            $wishlist->id_shop = $context->shop->id;
            $wishlist->id_shop_group = $context->shop->id_shop_group;
            $wishlist->default = 1;
            $mod_wishlist = new BlockWishList();
            $wishlist->name = $mod_wishlist->default_wishlist_name;
            $wishlist->id_customer = (int) $context->customer->id;
            list($us, $s) = explode(' ', microtime());
            srand($s * $us);
            $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $context->customer->id), 0, 16));
            $wishlist->add();
            $context->cookie->id_wishlist = (int) $wishlist->id;
        }
        if ($add && $quantity) {
            WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity);
        } else {
            if ($delete) {
                WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute);
            }
        }
    }
    $context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true));
    if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/blockwishlist/blockwishlist-ajax.tpl')) {
        $context->smarty->display(_PS_THEME_DIR_ . 'modules/blockwishlist/blockwishlist-ajax.tpl');
    } elseif (Tools::file_exists_cache(dirname(__FILE__) . '/blockwishlist-ajax.tpl')) {
        $context->smarty->display(dirname(__FILE__) . '/blockwishlist-ajax.tpl');
    } else {
        echo $module->l('No template found', 'cart');
    }
} else {
开发者ID:ortegon000,项目名称:tienda,代码行数:31,代码来源:cart.php

示例3: getAllProducts

    }
    public function getAllProducts()
    {
        return $this->products;
    }
    public function findProductByName($name)
    {
        $productKey = null;
        foreach ($this->products as $key => $product) {
            if ($product->name == $name) {
                $productKey = $key + 1;
                return $product . ' is number ' . $productKey . ' in the Wish List. <br />';
            } else {
                throw new Exception("No product with given name found in Wish List");
            }
        }
    }
}
$itemDescriber = new ItemDescriber();
$hoodie = new Clothing("Hoodie", "Nike", 19.99, "large", "red", "shirt", "male");
$plasma = new Television("Plasma", "Sony", 1000.0, plasma, "50in");
$wishList = new WishList();
$wishList->addProduct($hoodie);
$wishList->addProduct($plasma);
$shoppingCart = $wishList->createCartFromContainer($wishList);
$wishList->provideDescription();
$shoppingCart->provideDescription();
?>
    </p>
  </body>
</html>
开发者ID:ChuckPavlick,项目名称:challenges,代码行数:31,代码来源:02_hard.php


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