我正在加载这样的订单:
$order = Mage::getModel('sales/order')->load(2886);
$items = $order->getAllItems();
Run Code Online (Sandbox Code Playgroud)
然后我使用foreach循环:
foreach ($items as $itemId => $item){
$name[] = $item->getName();
$unitPrice[]=$item->getPrice();
$sku[]=$item->getSku();
$ids[]=$item->getProductId();
$qty[]=$item->getQtyToInvoice();
}
Run Code Online (Sandbox Code Playgroud)
而且我能够获得我需要的大部分数据.但是,我在获取为订单选择的自定义选项时遇到问题.我可以在var转储中看到数据,但是我没有成功挖掘它.我也尝试了一些我通过谷歌找到的内置函数,但没有运气.
这可能是一个初学者的问题,但没有太多的运气来实现这一目标.的背景:
问题是我无法使表单工作,但可以获得默认的Bootstrap示例代码,以相同的形式正确布局.Rails表单看起来像:
<div class="row-fluid">
<div class="span4 well">
<%= form_for @member, :html => {:class => "form-horizontal"} do |m| %>
<fieldset>
<%= m.label :title %>
<%= m.text_field :title %>
<%= m.label :first_name %>
<%= m.text_field :first_name %>
<% end %>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请注意,form_for方法具有form-horizontal类,如Bootsrap形式CSS中所述
显示时,标签(例如标题)位于左侧调整的一行上,然后下一行是输入字段,也是左侧调整的.
现在,如果我为表单包含一些示例Bootstrap代码,例如:
<div>
<form class="form-horizontal">
<fieldset>
<legend>Legend text</legend>
<div class="control-group">
<label class="control-label" for="input01">Text input</label>
<div class="controls">
<input type="text" class="input-xlarge" id="input01">
<p class="help-block">Supporting help text</p>
</div>
</div>
</fieldset> …Run Code Online (Sandbox Code Playgroud) 我的Rails.application.config.assets.paths包含我想要的资产的目录(自动完成):
- /Users/kiranb/application/app/assets/images
- /Users/kiranb/application/app/assets/javascripts
- /Users/kiranb/application/app/assets/stylesheets
- /Users/kiranb/application/vendor/assets/javascripts
- /Users/kiranb/application/vendor/assets/stylesheets
- /Users/kiranb/.rvm/gems/ruby-1.9.2-p290@application/gems/rails3-jquery-autocomplete-1.0.5/lib/assets/javascripts
- /Users/kiranb/.rvm/gems/ruby-1.9.2-p290@application/gems/jquery-rails-1.0.19/vendor/assets/javascripts
Run Code Online (Sandbox Code Playgroud)
autocomplete gem的lib/assets/javascripts包含:
autocomplete-rails-uncompressed.js autocomplete-rails.js
Run Code Online (Sandbox Code Playgroud)
我的application.js包括:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
但是,我一直收到错误:
couldn't find file 'autocomplete-rails' (in /Users/kiranb/application/app/assets/javascripts/application.js:11)
不过,它可以轻松找到任何其他资产.我究竟做错了什么?
我使用Sql Server Compact Edition数据库文件将数据存储在我的Windows应用程序软件中.
在这个数据库中,我有一个带有标识字段的表.
当我在表中插入记录时,身份代码会自动递增.但是当我从表中删除所有记录并再次插入一些记录时,标识字段不会从1开始.
如何将此值重置为1?
我想在客户端和服务器端都使用ES6.当然,我可以从终端启动我的NodeJS服务器babel-node src/app.js,但它无法调试.
另一方面,Webstorm 9声称它支持ES6,但是当我尝试启动默认的Node配置时,它会抱怨该a => a + 1功能.
问题:如何从Webstorm 9中启动NodeJS + ES6应用程序?
PS我使用Node 0.12.*版本PS我也试过这个但它也不适用于我
当这段代码(从babel生成)运行时,我收到一个错误 exports is undefined
Object.defineProperty(exports, '__esModule', {
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有这个if-else语句给了我奇怪的回应......每当我首先选择"输出"时,之后没有其他选择可以出现...仅供参考,我使用多选我所以我可以选择并显示我想要的数量.
$('#outputText').hide();
$('#armCB').hide();
$('#outputCB').hide();
$('#zoneText').hide();
$('#counterText').hide();
$('#flagText').hide();
$('#sensorText').hide();
('#select-choice-1').change(function(){
if ($('#output').is(':selected')){
$('#outputText').show();
}
else if ($('#arm').is(':selected')){
$('#armCB').show();
}
else if ($('#zone').is(':selected')){
$('#zoneText').show();
}
else if ($('#counter').is(':selected')){
$('#counterText').show();
}
else if ($('#flag').is(':selected')){
$('#flagText').show();
}
else if ($('#sensor').is(':selected')){
$('#sensorText').show();
}
else{
$('#outputText').hide();
$('#armCB').hide();
$('#zoneText').hide();
$('#counterText').hide();
$('#flagText').hide();
$('#sensorText').hide();
}
Run Code Online (Sandbox Code Playgroud)
我的if-else声明中有错误吗?或者我必须在这里使用Switch case语句吗?如果是这样,我该怎么办?
HTML:
<div id="display" style=" clear:both">
<div class="left" style="float:left; width:48%">
<div data-role="fieldcontain">
<label for="select-choice-1" class="select">Select Category</label>
<select name="select-choice-1" id="select-choice-1" data-native-menu="false" data-mini="true" multiple="multiple" size="2">
<option value="arm" id="arm">Arm</option>
<option value="zone" id="zone">Zone Input</option>
<option value="output" id="output">Output</option> …Run Code Online (Sandbox Code Playgroud) 我正在使用ES6类在Node中捆绑一些功能.这是(基本上)它的样子:
class processDocs {
constructor(id) {
this.id = id;
// console.log(this) returns { id: id }
}
getDocs(cb) {
// console.log(this) returns null
docs
.query(qb => {
qb.where('id', this.id);
})
.fetch()
.then(function(documents) {
cb(null, documents);
})
;
}
alterDocs(documents, cb) {
//some logic
}
reindexSearch(cb) {
//some logic
}
process() {
// console.log(this) returns { id: id }
async.waterfall([
this.getDocs,
this.alterDocs,
this.reindexSearch
]);
}
}
export default processDocs;
Run Code Online (Sandbox Code Playgroud)
我认为使用ES6类,分配公共变量的方法是简单引用this,通过构造函数初始化这些变量的方式正是它在我的类定义中显示的方式.
这是我如何调用类(在单独的文件中):
var Processor = require('./processDocs');
var pr = new …Run Code Online (Sandbox Code Playgroud) 我用ES6编写了我的React应用程序.现在我想用ES6编写我的测试.所以这里的挑战是配置业力.
和谷歌一起,我带着karma.config.js走了这么远(我省略了配置文件的相同部分!):
...
files: [
'../node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js',
'../app/**/*.jsx',
'../test/**/*.jsx'],
preprocessors: {
'app/**/*.jsx': ['react-jsx', 'babel'],
'test/**/*.jsx': ['react-jsx', 'babel']
},
'babelPreprocessor': {
options: {
sourceMap: 'inline'
},
filename: function(file) {
return file.originalPath.replace(/\.jsx$/, '.es5.js');
},
sourceFileName: function(file) {
return file.originalPath;
}
},
....
Run Code Online (Sandbox Code Playgroud)
我认为这个设置应该做什么:1)将JSX编译为JS,接下来babel应该将ES6转换为ES5.这与polyfill我预期的一起应该在phantomjs中运行.但不,这是我运行时来自业力的输出:
PhantomJS 1.9.8 (Mac OS X) ERROR
SyntaxError: Parse error
at Projects/ES6/app/js/app.jsx:35
PhantomJS 1.9.8 (Mac OS X): Executed 0 of 0 ERROR (0.027 secs / 0 secs)
[20:36:59] Karma has exited with 1
Run Code Online (Sandbox Code Playgroud)
第35行app.jsx包含实际的JSX部分.因此,出于某种原因,预处理器似乎并没有那么多.任何有关预处理器的帮助都会受到赞赏吗?
更新:我有这个几乎工作的nog.事实证明我应该像这样交换我的预处理器 …
我正在尝试将新条目添加到我有此查询的表中
$scope.addClient = function() {
var clientId = $scope.items.length;
//alert(empid);
$scope.client.id = clientId++;
$scope.items.push($scope.client);
}
Run Code Online (Sandbox Code Playgroud)
这是我的表格
<div>
<div class="modal-header">
<h2>Ajouter client</h2>
</div>
<form role="form" ng-submit="addClient()">
<div class="modal-body">
<label for="name">Nom : </label>
<input type="text" id="name" class="form-control input" ng-model="client.name" value=" {{client.name}}" />
<label for="age">Age : </label>
<input type="text" id="age" class="form-control input" ng-model="client.age" value="{{client.age}}" />
<label for="gender">Sexe : </label>
<input type="text" id="gender" class="form-control input" ng-model="client.gender" value="{{client.gender}}" />
<label for="email">Email : </label>
<input type="text" id="email" class="form-control input" ng-model="client.email" value="{{client.email}}" />
<label for="company">Société : </label> …Run Code Online (Sandbox Code Playgroud) babeljs ×4
ecmascript-6 ×3
javascript ×2
node.js ×2
angularjs ×1
forms ×1
identity ×1
if-statement ×1
jquery ×1
karma-runner ×1
magento ×1
php ×1
react-jsx ×1
reactjs ×1
webstorm ×1