只允许管理员在Magento前端购买产品(Only allow administrator to buy products in Magento frontend)
我需要以某种方式设置一个Magento商店来禁止购买一些产品,而是显示一条消息,他们只能在实体店购买。 扭曲的是商店所有者/管理员必须能够代表客户在前端 “购买”这些产品 - 所有付款选项在后端都不可用。
那么,有没有办法只允许某些客户/用户购买某些产品,并向所有其他客户和匿名访客显示“非卖品”通知? (不是“缺货”。)
我曾想过创建一个特殊的商店视图或自定义设计,甚至使用一些Javascript技巧来防止未经授权的访问者购买这些产品。 任何聪明的想法?
I need to somehow setup a Magento store to disable purchasing of a few products, and instead show a message that they can only be bought in the physical store. The twist is that the store owner/administrator has to be able to "buy" these products on the frontend on behalf of the customer -- all payment options are not available in the backend.
So, is there a way to only allow certain customers/users to purchase certain products, and show all other customers and anonymous visitors a "not for sale" notice? (Not "out of stock".)
I have thought of creating a special store view or custom design, or even using some Javascript trickery to prevent unauthorized visitors to purchase these products. Any clever ideas?
原文:https://stackoverflow.com/questions/13455290
最满意答案
实际得到输出的结果很大程度上取决于
num
等于什么,但为了理解这一特定的代码行,必须分解各个函数。首先,内部有两个使用map函数使用字符串创建的可迭代地图。
第一个是从变量
num
到0的所有数字,不包括在内。 所以如果num
是4,那么这张地图会有num
和1个。第二张地图从2开始计数至
num + 1
,不包括在内。 所以如果num
是4,那么它会在地图上是2,3和4。接下来,这两个地图都用空格连接起来,这样每个地图都会变成一个在每个值之间都有空格的字符串。 前面例子中的第一张地图是
"4 3 2 1"
,第二张地图是"2 3 4"
。 +然后将这两个字符串连接在一起,以便它们成为单个字符串,这可以从我们的示例"4 3 2 12 3 4"
。最后,len找到这个组合字符串的长度,并将该值保存到
string_width
,在我们的示例中该值为12,因为那是多少个字符(它计数空格)。What actually gets output is very dependent on what
num
equals, but to understand this specific line of code you must break down the individual functions.First, internally there are two iterable maps created with strings using the map function.
The first is all the numbers from the variable
num
counting down to 0, non inclusive. So ifnum
was 4, this map would have 4, 3, 2, and 1 in it.The second map starts at 2 and counts up to
num + 1
, non inclusive. So ifnum
was 4, it would be 2, 3, and 4 in the map.Next, both of the maps are joined with spaces so each one becomes a string with spaces in between each of its values. The first map from the previous example would be
"4 3 2 1"
and the second would be"2 3 4"
. The + then concatenates these two strings together so they become a single string, which would be from our examples"4 3 2 12 3 4"
.Finally, len finds the length of this combined string and that value is saved into
string_width
, which in our example would be 12, because that is how many characters there are (it counts spaces).
相关问答
更多-
这条线是什么解释(what does this line interpret)[2023-03-06]
实际得到输出的结果很大程度上取决于num等于什么,但为了理解这一特定的代码行,必须分解各个函数。 首先,内部有两个使用map函数使用字符串创建的可迭代地图。 第一个是从变量num到0的所有数字,不包括在内。 所以如果num是4,那么这张地图会有num和1个。 第二张地图从2开始计数至num + 1 ,不包括在内。 所以如果num是4,那么它会在地图上是2,3和4。 接下来,这两个地图都用空格连接起来,这样每个地图都会变成一个在每个值之间都有空格的字符串。 前面例子中的第一张地图是"4 3 2 1" ,第二张 ... -
在“经典”C ++语言中,您有两种形式的初始化语法: 副本初始化 int i = 5; 和直接初始化 int i(5); 它们并不总是完全相同,但是出于基本意图和目的,它们会做同样的事情。 (C ++ 11进一步扩展了变化,但我不会在这里进行讨论。)在上面的例子中,它们实际上是完全相同的:变量i在两种情况下都将用5初始化。 所以你的 string cmd(*iter); 具有相同的效果 string cmd = *iter; 即它初始化字符串cmd ,其值为*iter ,其中iter可能是某种迭代器 ...
-
这条“最大”线是什么意思?(What does this “max” line mean?)[2024-03-18]
三元运算符?:计算它的第一个参数,如果是,则返回第二个,否则返回第三个。 因此,如果sockfd1 < sockfd2 ,结果将是sockfd2 ,否则sockfd1 - 换句话说, max接收数字更大的套接字文件描述符。 The ternary operator ?: evaluates its first argument, and if it's true, it returns the second, otherwise the third. So if sockfd1 < sockfd2, the ... -
Plot:解释输出(Plot : Interpret the output)[2022-05-11]
绘图函数的工作原理:给出一些x值和相同数量的y值,它将绘制它们。 但是,您也可以为多个y数组plot ,因此可以使用相同的x值绘制多个函数。 在您的第一个图中,您正在绘制3个函数: plot([0.1 0.2], [1 0]) plot([0.1 0.2], [1 1]) plot([0.1 0.2], [0 1]) 在图中有3个图,但是,你的轴太紧,你不能看到它们,因为一个是水平线而另一个是垂直线。 如果你写axis([0 0.3 -1 2])你会看到三条线。 你的其他情节也会发生同样的事情,你为每个x ... -
帮助解释此堆栈跟踪(Help interpret this stack trace)[2022-01-12]
你正在检查this->cstr_为null,但是你没有检查other.cstr_ 。 也许容器会阻止插入具有null cstr_值的任何字符串,因此不需要进行此类检查。 然而,这不是问题,因为在这种情况下其他不是null。 而是看起来other对象可能已被删除。 你如何管理std::map容器中对象的生命周期? 是否有可能删除其中一个值而未从地图中删除? 更新: 在进一步检查时,这似乎是关键: #5 0x0013383a in std::map<...>::find (this=0x83173a0, __ ... -
以下代码分两步执行 isSelected = ii === this.state.selectedIndex 1. ii === this.state.selectedIndex // comparator operator 2. isSelected = (result of step 1) // assignment operator The following code is executed in 2 steps isSelected = ii === this.state.selectedIn ...
-
感谢@twotwotwo的评论,我想我明白了这一点。 在这一行 github.com/DataDog/datadog-go/statsd.(*Client).Event(0x0, 0xc8200c7ec8, 0x0, 0x0) 第一个0x0是*Client ,实际上它是零。 0xc8200c7ec8是*Event 下面的0x0, 0x0代表类型error的返回值。 根据http://blog.golang.org/error-handling-and-go , error是一个接口。 根据http://r ...
-
这条线说什么......?(what does this line says…?)[2023-12-27]
作者通过在其类之外说代码意味着什么?哪些代码正在调用它..? 调用方法的是JVM,因此,在这种情况下,“在其类之外”应该被解释为“由JVM”。 从技术上讲,JVM不是包含主要方法的类的一部分,因此该方法必须公开才能调用它。 what do the author mean by saying code outside of its class.. which code is calling it..? It is the JVM that calls the method, so, yes, "outside ... -
这是一个三元运算符 ,用作速记条件语句: 这跟说: if ($.browser.mozilla) { mouseWheelEventName = 'DOMMouseScroll'; } else { mouseWheelEventName = 'mousewheel'; } =之前的第一个部分是根据以下条件声明变量(mouseWheelEventName)。 下一篇= ? 条件是( $.browser.mozilla是吗?)。 紧接着? 是then部分(如果条件为true,则将变量mous ...
-
如何解释这个图(How To Interpret This Diagram)[2022-06-26]
键符号表示主键或PK。 外键(FK)没有任何符号,但你可以猜到。 例如, student.dept_name是来自department.dept_name FK 箭头从department到student意味着一个部门有0 to N学生 它们是两个符号,从第一行开始,一个是圆圈,另一个是一个粗线。 我猜一个是0 .. N和另一个1 .. N但是不知道你是怎么做的那个图不能确定。 此图表称为ER或实体关系 每个框都是您必须在脚本中创建的表或实体,然后创建PK,然后定义FK。 A Key symbol mean ...