option

Add a custom option to a quote item (product in the cart)?

巧了我就是萌 提交于 2019-12-05 16:56:52
问题 I'm running Magento 1.7. I'm trying to add a quote item option, a custom one, in sales_flat_quote_item_option. I have tried with addOption and addCustomOption functions, but it seems no query is launched to the database. This is my code right now (in a custom module helper) : public function assignDocumentToQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem, $documentid) { if (is_numeric($documentid) && $documentid > 0) { /** @var Mage_Catalog_Model_Product */ $product = $quoteItem->getProduct(

jQuery: find the <optgroup> for a selected value in a <select> element

只愿长相守 提交于 2019-12-05 15:46:51
问题 I have a dropdown menu with different option groups. If someone selects an option, how can I check which optgroup it belongs to? For example if 'ferrari' were selected, how would you determine which optgroup it belongs to? Feel free to use jQuery or raw javascript. <select name="testSelect"> <optgroup label="fruits"> <option value="apples">Apples</option> <option value="oranges">Oranges</option> <option value="pears">Pears</option> </optgroup> <optgroup label="cars"> <option value="ford">ford

Scala: Something like Option (Some, None) but with three states: Some, None, Unknown

让人想犯罪 __ 提交于 2019-12-05 07:38:32
I need to return values, and when someone asks for a value, tell them one of three things: Here is the value There is no value We have no information on this value (unknown) case 2 is subtly different than case 3. Example: val radio = car.radioType we know the value: return the radio type, say "pioneer" b. there is no value: return None c. we are missing data about this car, we don't know if it has a radio or not I thought I might extend scala's None and create an Unknown, but that doesn't seem possible. suggestions? thanks! Update: Ideally I'd like to be able to write code like this: car

Add selected attribute to option in select menu with jQuery

北战南征 提交于 2019-12-05 03:42:27
I'm making a select menu plugin to replace the ugly default selects and be consistent across different OS. Here's the demo (only firefox and webkit) http://spacirdesigns.com/selectMenu/ It's already working, but I'm having problems assigning the "selected" attribute to the option. The code works with any other attribute but I can't get it to work with the selected attribute. This works: select.find('option') .removeAttr('whatever') .eq(index).attr('whatever', 'hello'); This doesn't: select.find('option') .removeAttr('selected') .eq(index).attr('selected', 'selected'); And here's the code so

[Scala] 用 Option[T] 来避免 NullPointerException(整理)

佐手、 提交于 2019-12-05 01:20:53
前言 Java 里的 Null Pointer Exception 写过一阵子的Java后, 应该会对NullPointerException (NPE)这种东西很熟悉,基本上会碰到这种异常,就是你有一个变量是 null,但你却调用了它的方法,或是取某个的值。 举例而言,下面的 Java 代码就会抛出NPE异常: 例1: String s1 = null; System.out.println("length:" + s1.length()); 当然,一般来说,我们很少会写出这么明显的错误代码。 但另一方,在 Java 的使用习惯说,我们常常以「返回 null」这件事,来代表一个函数的返回值是不是有意义。 例2: //就是在 Java 里 HashMap 的 get() 方法,如果找不到对应的 key 值,就会反回 null: HashMap<String, String> myMap = new HashMap<String, String>(); myMap.put("key1", "value1"); String value1 = myMap.get("key1"); // 返回 "value1" String value2 = myMap.get("key2"); // 返回 null System.out.println(value1.length()); // 没问题

Why does Rust need the `if let` syntax?

我是研究僧i 提交于 2019-12-05 00:36:01
Coming from other functional languages (and being a Rust newbie), I'm a bit surprised by the motivation of Rust's if let syntax. The RFC mentions that without if let , the "idiomatic solution today for testing and unwrapping an Option<T> " is either match opt_val { Some(x) => { do_something_with(x); } None => {} } or if opt_val.is_some() { let x = opt_val.unwrap(); do_something_with(x); } In Scala, it would be possible to do exactly the same, but the idiomatic solution is rather to map over an Option (or to foreach if it is only for the side effect of doing_something_with(x) ). Why isn't it an

vue.js :selected doesn't triggering @change event select/option

喜夏-厌秋 提交于 2019-12-04 19:27:16
I have prop "cat" props: ['cat1'], Ant this piece of code <select class="form-control" @change="set_category"> <option value="" disabled>Please select category</option> <option v-for="category in categories" :value="category" :selected="cat1 == category.url">{{ category.name}} </option> </select> So this code is called when page its loading and the problem is, that after loading the page option changes but it doesn't triggers @change event, ant because of it i can't actually track which option was selected on page load. I tried alot versions with v-model ant etc but it sees i just stuck on it.

省市县三级联动(第2版)

╄→гoц情女王★ 提交于 2019-12-04 19:11:28
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <style type="text/css"> .question-select { height: 40px; } .question-select select { border-radius: 5px; box-shadow: 0 0 5px #ccc; appearance: none; -webkit-appearance: none; -moz-appearance: none; border: none; outline: none; height: 100%; padding: 0 20px; color: #333; font-size: 22px; } .question-select select.long { width: 300px; } .question-select select.short { width: 150px; } </style> <body> <div id="example"> <div class="question-select"> <select v-model="currentProvince" class="short"> <option v-for="option in

网页程序迁移至微信小程序web-view详解

我怕爱的太早我们不能终老 提交于 2019-12-04 17:42:40
小程序现在越来越流行,但是公司的很多项目都是用网页写的,小程序语法不兼容原生网页,使得旧有项目迁移至小程序代价很高; 小程序之前开放了webview功能,可以说是网页应用的一大福音了,但是微信的webview有一些坑,这篇文章就是列举一下我在开发过程中遇到的一些问题以及我找到的一些解决方案。 遇到的问题 openid登录问题 webview动态src 支付功能 分享功能 扫描普通二维码跳转特定页面 返回按钮缺失问题 openid登录问题 微信webview的使用方法很简单,只要如下设置src就可以展示具体的网站了。 <!-- wxml --> <!-- 指向微信公众平台首页的web-view --> <web-view src="https://mp.weixin.qq.com/"></web-view> 微信环境里的很多网页都是用页面要实现网站的登录功能,只要把登录的信息,比如openid或者其他信息拼接到src里就好了。 这里有个问题,公众号的账号体系一般是以openid来判断唯一性的,小程序是可以获取openid的,但是小程序的openid和原公众号之类的openid是不一样的,需要将原先的openid账号体系升级为unionid账号体系。 以下是微信对unionid的介绍 获取用户基本信息(UnionID机制) 在关注者与公众号产生消息交互后