我正在研究一种打包产品,该产品应该满足不同要求(在一定程度上)的多个客户,因此应该以足够灵活的方式构建,以便每个特定客户可以定制.我们在这里讨论的那种定制是不同的客户端可能对某些关键业务对象具有不同的属性.此外,他们也可以将不同的业务逻辑与其附加属性联系起来
作为一个非常简单的例子:将 "汽车"视为系统中的商业实体,因此有4个关键属性,即VehicleNumber,YearOfManufacture,Price和Color.
使用该系统的其中一个客户端可能会向Automobile添加另外两个属性,即ChassisNumber和EngineCapacity.此客户端需要与这些字段关联的一些业务逻辑,以验证添加新汽车时系统中不存在相同的chassisNumber.
另一个客户端只需要一个名为SaleDate的附加属性.SaleDate有自己的业务逻辑检查,当输入销售日期时,该检查验证某些警方记录中的车辆是否作为被盗车辆存在
我的大多数经验主要是为单个客户端制作企业应用程序,我真的很难看到我如何处理其属性是动态的业务实体,并且还具有在面向对象范例中具有动态业务逻辑的能力.
关键问题
我相信从事通用/包装产品的人在大多数情况下都会面临类似的情况.任何建议/指针/一般指导也不胜感激.
我的技术是.NET 3.5/C#,该项目有一个分层架构,其业务层由包含业务逻辑的业务实体组成
好了,阅读Woocommerce 3.0+的变化,似乎你不能再直接访问这个类了,所以我认为这个代码需要改变,因为它正在吐出一个错误:
$order_item_id = 15;
$order_item = new WC_Order_Item_Product($order_item_id);
$return = $order_item->get_id() ? $order_item : false;
Run Code Online (Sandbox Code Playgroud)
但是,令人尴尬的是,我不确定如何更改此代码以在此类的最新版本中使用正确的新getter和setter函数,该类不再具有构造.怎么做得好?我没有看到任何get
关于获得订单项的功能与上述相同.
https://docs.woocommerce.com/wc-apidocs/class-WC_Order_Item_Product.html
也许我在这里忽视一些事情?
我有一个可配置的产品有3个选项,见下文:
我想用产品的实际价格替换+ 24.00英镑和+ 75.00英镑.
所以相反它会说:£69.00和£120.00
我找到了js/varien/product.js中的代码
我花了一些时间来切换和更改代码,但无法完全解读需要更改的内容.此文件中的第240行向下处理可配置产品的JavaScript事件.
我很感激这里有任何帮助.
我正在用PHP做一个非常小的在线商店应用程序.所以我在PHP中有一组地图.我想在数组中搜索字符串(产品).我在PHP中查看了array_search,似乎只查找完全匹配.你们知道更好的方法来实现这个功能吗?因为这只是我实际做的一小部分,所以我希望有一些内置的东西.任何想法?
谢谢!
编辑:该数组包含以下格式的"产品":
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 2000-YM
)
[Name] => Team Swim School T-Shirt
[size] => YM
[price] => 15
[group] => Team Clothing
[id] => 2000-YM
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 3000-YS
)
[Name] => Youth Track Jacket
[size] => YS
[price] => 55
[group] => Team Clothing
[id] => 3000-YS
)
Run Code Online (Sandbox Code Playgroud)
所以我想知道我可以做一个搜索,比如"团队",这会让我看到第一个看到这里的项目.我的搜索基于名称(这只是一个小的东西).我知道我可以找到确切的字符串,如果它找不到确切的项目,我只是坚持"最佳结果".效率很好但不是必需的,因为我只有大约50项,所以即使我使用"慢"算法也不会花费太多时间.
在Woocommerce中,您可以添加全局产品属性和术语.例如:
Size (attribute)
small (term)
medium (term)
large (term)
Run Code Online (Sandbox Code Playgroud)
这与产品无关.然后,您可以从产品上的预定义属性中进行选择.
我需要使用php获取属性中的所有术语.因此,选择所需的属性,例如大小,然后返回包含的数组[small,medium,large]
.
看起来很简单,但我找不到任何帮助.
我认为这段代码应该有效,但不能确定将它放在何处.我到过的每个地方到目前为止都失败了......
add_action('init', 'woocommerce_clear_cart');
function woocommerce_clear_cart() {
global $woocommerce, $post, $wpdb;
$url = explode('/', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$slug=$url[4];
$postid = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status='publish' AND post_name = '$slug'");
if ($postid){
if ($postid == PRODUCTID1 || $postid == PRODUCTID2){
$woocommerce->cart->empty_cart();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我一直在为Magento(版本1.8.0.0)开发一个自定义模块,它显示了某个产品的相关产品列表.
为了实现这一点,我通过覆盖Mage_Catalog_Block_Product_List
类创建了自己的模块.
基本上这是它的工作原理:
从控制器我捕获产品entity_id
,我将产品存储在注册表中,以便我可以在我的自定义写入块中使用它,该块名为list.php
以下是填充产品集合的方法:
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$prod = Mage::registry('chosenproduct');
$this->_productCollection = $prod->getRelatedProductCollection()
->addAttributeToSelect('required_options')
->addAttributeToFilter(array(array('attribute'=>'accessory_manufacturer','neq'=>false)))
->addAttributeToSort('position', 'asc')
->addStoreFilter()
->setPageSize(30)
->setCurPage(1);
;
$this->_addProductAttributesAndPrices($this->_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_productCollection);
$this->setProductCollection($this->_productCollection);
}
return $this->_productCollection;
}
Run Code Online (Sandbox Code Playgroud)
我还在自定义模块的布局.xml中添加了以下内容,以确保分层导航显示:
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
Run Code Online (Sandbox Code Playgroud)
分层导航显示,但似乎它将所有产品作为集合而不是我在上面添加的方法中使用的自定义集合.
我也知道我可以使用它来获取目录/图层 $layer = Mage::getSingleton('catalog/layer');
图层类还有一个名为prepareProductCollection和setCollection的方法,但由于某种原因我无法使其工作.
对此有何帮助?
基本上我想为自定义集合中的产品进行分层导航.
谢谢,
我希望能够使用PHP通过产品ID回显产品名称来显示产品标题(这将显示在页面内,而不是产品页面本身).我正在使用Wordpress,我有一个PHP插件,所以我可以使用PHP代码[php]echo 'example';[/php]
一个产品示例是; http://ukcctvinstallations.co.uk/product/1-camera-residential-system-hi-res/
当我编辑产品时,您可以在URL中看到"发布"= 129,所以我说这是产品ID吗?
如果有人有解决方案,那将非常感激.我正在使用WooCommerce.
在阅读Bartosz 为程序员提供的优秀类别理论时,我陷入了第二个练习,即第二个练习,它处理了网络中的产品.鉴于一个poset,
b e
? ? ?
a ? c f ? h
? ? ?
d g
Run Code Online (Sandbox Code Playgroud)
如何在分类意义上定义产品?什么是两个对象的产品分类?那副产品呢?
在WooCommerce中,我需要将所有产品价格乘以一个数字.所以我使用了以下内容(通过插件):
add_filter('woocommerce_get_regular_price', array( $this, 'my_custom_price'), 99);
add_filter('woocommerce_get_price', array( $this, 'my_custom_price'), 99);
function my_custom_price( $original_price ) {
global $post, $woocommerce;
//Logic for calculating the new price here
$new_price = $original_price * 2;
//Return the new price (this is the price that will be used everywhere in the store)
return $new_price;
}
Run Code Online (Sandbox Code Playgroud)
但是,这对变体产品不起作用.我试过以下钩子没有运气:
add_filter('woocommerce_get_variation_regular_price', array( $this, 'my_custom_price'), 99);
add_filter('woocommerce_get_variation_price', array( $this, 'my_custom_price'), 99);
Run Code Online (Sandbox Code Playgroud)
唯一有效的是这一个:
add_filter('woocommerce_variation_prices_price', array( $this, 'my_custom_price'), 99);
Run Code Online (Sandbox Code Playgroud)
但这只是改变了整体价格,而不是选定的变化价格.见下图,价格是BsF.200和整体价格是正确的,200 x 2 = 400,但选择时的变化价格仍显示200:
注意:我需要它实际更改,所以显示html钩子不会工作.
有什么我想念的,或者有什么不对吗?
product ×10
woocommerce ×5
php ×4
wordpress ×4
magento ×2
arrays ×1
attributes ×1
cart ×1
collections ×1
configurable ×1
e-commerce ×1
layered ×1
navigation ×1
oop ×1
options ×1
orders ×1
poset ×1
price ×1
search ×1
shopping ×1
store ×1