我正在尝试更改Magento现有订单的运费.这在管理员后端工作正常,即使这是一个非常重要的过程,因为我必须在发货地址对象上设置新的发货方法并重新计算报价总计后手动更新许多订单字段/属性.
我的问题是在前端运行相同的代码,它根本不起作用,报价collectTotals将恢复我在shippingAddress中所做的任何更改,我不知道如何解决它或为什么它的工作原理后端.
这就是它的样子:
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setShippingMethod('dynamicshipping_'.$shippingCode);
$shippingAddress->setCollectShippingRates(true);
$shippingAddress->collectShippingRates();
$quote->setUseCustomerBalance(1)->setTotalsCollectedFlag(false)->collectTotals()->save();
$order->setShippingHiddenTaxAmount($shippingAddress->getShippingHiddenTaxAmount());
$order->setBaseShippingHiddenTaxAmount($shippingAddress->getBaseShippingHiddenTaxAmount());
$order->setBaseShippingHiddenTaxAmnt($shippingAddress->getBaseShippingHiddenTaxAmnt());
$order->setShippingInclTax($shippingAddress->getShippingInclTax());
$order->setBaseShippingInclTax($shippingAddress->getBaseShippingInclTax());
$order->setShippingTaxAmount($shippingAddress->getShippingTaxAmount());
$order->setBaseShippingTaxAmount($shippingAddress->getBaseShippingTaxAmount());
$order->setShippingAmount($shippingAddress->getShippingAmount());
$order->setBaseShippingAmount($shippingAddress->getBaseShippingAmount());
$order->setShippingDiscountAmount($shippingAddress->getShippingDiscountAmount());
$order->setBaseShippingDiscountAmount($shippingAddress->getBaseShippingDiscountAmount());
$order->setGrandTotal($shippingAddress->getGrandTotal());
$order->setBaseGrandTotal($shippingAddress->getBaseGrandTotal());
$order->setShippingMethod('dynamicshipping_'.$shippingCode);
$order->setShippingDescription($shippingDescription);
$order->setServicePoint($servicePoint);
$order->save();
Run Code Online (Sandbox Code Playgroud)
正如我所说,每次从后端开始工作都很好,但是从前端调用时却没有.
我尝试过各种各样的变种,比如试图消除旧运输方法的任何痕迹,没有运气.
$quote->getShippingAddress()->removeAllShippingRates()
->setShippingMethod('dynamicshipping_'.$shippingCode)
->setShippingDescription($shippingDescription)
//->setBaseShippingAmount(0)
//->setBaseShippingTaxAmount(0)
//->setShippingTaxAmount(0)
//->setShippingInclTax(0)
->setCollectShippingRates(true)
//->unsetData('cached_items_all')
//->unsetData('cached_items_nominal')
//->unsetData('cached_items_nonnominal')
->collectShippingRates()
//->collectTotals()
->save();
Run Code Online (Sandbox Code Playgroud)
当我打电话给collectTotals时,无论我做什么,它都会让我看起来好像报价是使用旧的/不同的送货地址副本.
任何建议,或者也许是洞察它甚至可能在后端而不是前端工作?
编辑
经过更多调试后,我可以看到运输确实在前端和后端都发生了变化.问题是,只有在通过后端运行此代码时才会更改费用.很奇怪.它只是拒绝更新运费.
给定一个字符串向量,我想创建一个没有引号的表达式.
# eg, I would like to go from
c("string1", "string2")
# to... (notice the lack of '"' marks)
quote(list(string1, string2))
Run Code Online (Sandbox Code Playgroud)
我在删除引号时遇到了一些困难
input <- c("string1", "string2")
output <- paste0("quote(list(", paste(input, collapse=","), "))")
# not quite what I am looking for.
as.expression(output)
expression("quote(list(string1,string2))")
Run Code Online (Sandbox Code Playgroud)
library(data.table)
mydt <- data.table(id=1:3, string1=LETTERS[1:3], string2=letters[1:3])
result <- ????? # some.function.of(input)
> mydt[ , eval( result )]
string1 string2
1: A a
2: B b
3: C c
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它提供了一些HTML.然后需要将该HTML放入字符串中.此HTML包含单引号和双引号.是否有可能在javascript中声明一个包含信息的字符串,不使用单引号或双引号?
谢谢,我想如果不可能,有没有人知道一个简单易行的方法来逃避这些引号,所以我可以把它放在一个字符串?请记住,此字符串的一部分将是我稍后需要执行的javascript.
谢谢!
喜欢在标题...由于某种原因,magento网站不应用优惠券代码...总是返回无效的"优惠券代码无效"消息.但奇怪的是,当购物车的价格大于120我的货币时会发生这种情况.
示例:如果我在购物车中有一个价格为65的产品,则优惠券代码可以正常工作...如果我在购物车中有相同的产品但是数量为2(这意味着总价格变为130)我得到上述无效错误信息
我已经将代码追溯到"Mage_Sales_Model_Quote"类,它有一个名为:_validateCouponCode()的函数,里面有以下内容:$ address-> hasCouponCode()总是返回false ...我该怎么办?...我重新索引,刷新缓存......等等...没有改变...我似乎无法在地址模型中找到hasCouponCode函数,看看那里发生了什么...非常感谢提前
我正在运行Magento 1.7.
我正在尝试在sales_flat_quote_item_option中添加一个引用项选项,一个自定义选项.
我尝试过addOption和addCustomOption函数,但似乎没有向数据库启动查询.
这是我的代码(在自定义模块助手中):
public function assignDocumentToQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem, $documentid)
{
if (is_numeric($documentid) && $documentid > 0) {
/** @var Mage_Catalog_Model_Product */
$product = $quoteItem->getProduct();
$quoteItem->addOption(array(
'product_id' => $product->getId(),
'product' => $product,
'code' => 'documentid',
'value' => $documentid
));
$quoteItem->save();
return true;
}
throw new Exception(__METHOD__.' - Document id has to be a numeric value.');
}
Run Code Online (Sandbox Code Playgroud) 我想通过字符串变量选择一个列,但最重要的是我还想通常选择第二列.我需要这个,因为我有一个函数,它通过给定的参数选择几列.
我有以下代码作为示例:
library(dplyr)
data(cars)
x <- "speed"
cars %>% select_(x, dist)
Run Code Online (Sandbox Code Playgroud) 根据 Facebook 开发文档,共享参数“quote”应插入文本:
https://developers.facebook.com/docs/sharing/reference/share-dialog/
这似乎在前一周有效,但现在甚至使用他们自己的测试工具(http://www.fbrell.com/Sharing/2%20-%20FB.ui%20Dialogs?fbclid=IwAR2TX_eOex-HmIqbIfz9sakxN_laCAVVW_g6p-dW54WwVZkXQ_u5VZi8OCE), quote 参数似乎没有将任何文本插入弹出的共享对话框中。
还有其他人遇到过这种情况吗?
我有一个相当愚蠢的问题.Struts2属性标记不会转义单引号(').这种行为破坏了我的JavaScript代码.它确实使用html实体转义双引号("),但不是单引号(').是否有可能强制属性标记用适当的html实体替换单引号?
例如,字符串替换为html实体.Отредактированноесобытиескавычкой "
单个qoute相同:Отредактированноесобытиескавычкой '
有没有可能使用标准方法克服这种困难?我不想写一些自定义代码.
每个人都说eval是邪恶的,你应该用$()代替.但是我遇到了一种情况,即$()内部的unquoting处理方式不同.
背景是我经常被包含空格的文件路径烧掉,所以喜欢引用所有这些路径.关于想知道我的所有可执行文件来自何处的更多偏执狂.更偏执,不相信自己,所以能够显示我即将运行的创建命令.
下面我尝试使用eval与$()的变体,以及是否引用命令名称(因为它可能包含空格)
BIN_LS="/bin/ls"
thefile="arf"
thecmd="\"${BIN_LS}\" -ld -- \"${thefile}\""
echo -e "\n Running command '${thecmd}'"
$($thecmd)
Running command '"/bin/ls" -ld -- "arf"'
./foo.sh: line 8: "/bin/ls": No such file or directory
echo -e "\n Eval'ing command '${thecmd}'"
eval $thecmd
Eval'ing command '"/bin/ls" -ld -- "arf"'
/bin/ls: cannot access arf: No such file or directory
thecmd="${BIN_LS} -ld -- \"${thefile}\""
echo -e "\n Running command '${thecmd}'"
$($thecmd)
Running command '/bin/ls -ld -- "arf"'
/bin/ls: cannot access "arf": No …Run Code Online (Sandbox Code Playgroud) 最近,我一直在思考Lisp的基础; 我在互联网上阅读了几本手册和/或其他材料,包括P. Graham 的Lisp of Roz:
在Lisp的根中,quote被描述为将代码更改为数据的原语,从而引用它,但似乎没有等效的反向原语,即unquote原语.我认为它可能eval是业务,但eval经常在空词法环境中运行数据,这不等于将数据更改回代码.
Ergo,为什么不存在unquoteLisp原语?