首页 \ 问答 \ 只允许管理员在Magento前端购买产品(Only allow administrator to buy products in Magento frontend)

只允许管理员在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
更新时间:2023-05-21 11:05

最满意答案

实际得到输出的结果很大程度上取决于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 if num 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 if num 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).

相关问答

更多
  • 实际得到输出的结果很大程度上取决于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可能是某种迭代器 ...
  • 三元运算符?:计算它的第一个参数,如果是,则返回第二个,否则返回第三个。 因此,如果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 ...
  • 绘图函数的工作原理:给出一些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 ...
  • 你正在检查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 ...
  • 作者通过在其类之外说代码意味着什么?哪些代码正在调用它..? 调用方法的是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 ...
  • 键符号表示主键或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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)