1.the ajax function in cart page phtml:
function change($this){ //update cart item qty var item_id = $this.attr('item_id'); var qty = $this.val(); $("#ajax-loading-div").show(); $.ajax({ url: "<?php echo $this->getUrl('mycheckout/cart/updateProductQty');?>", type: "POST", dataType:"json", data:{item_id:item_id,qty:qty}, success: function(data) { //update the cart page $('.big-cart').html(data['big_cart']); //update the cart header $('.cart-header').html(data['cart_header']); //update the cart header count; $('#top_link_cart').html(data['cart_header_cnt_text']); //hide the loding box $("#ajax-loading-div").hide(); } }); }
2.the php function for ajax:
public function updateProductQtyAction() { $item_id = Mage::app()->getRequest()->getParam('item_id'); $qty = Mage::app()->getRequest()->getParam('qty'); Mage::getSingleton('core/session', array('name'=>'frontend')); // GET THE SESSION $simbol= Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); // GET THE CURRENCY SIMBOL $store=Mage::app()->getStore()->getCode(); // GET THE STORE CODE $cart = Mage::getSingleton('checkout/cart'); //->getItemsCount(); $items = $cart->getItems(); foreach ($items as $item) { // LOOP if($item->getId()==$item_id){ // IS THIS THE ITEM WE ARE CHANGING? IF IT IS: $item->setQty($qty); // UPDATE ONLY THE QTY, NOTHING ELSE! $cart->save(); // SAVE Mage::getSingleton('checkout/session')->setCartWasUpdated(true); break; } } $data = array(); $block = $this->getLayout()->createBlock('checkout/cart_sidebar'); $block->setTemplate('checkout/cart/cartheader-ajax.phtml') ->addItemRender('simple','checkout/cart_item_renderer','checkout/cart/sidebar/default.phtml') ->addItemRender('grouped','checkout/cart_item_renderer_grouped','checkout/cart/sidebar/default.phtml') ->addItemRender('configurable','checkout/cart_item_renderer_configurable','checkout/cart/sidebar/default.phtml'); $html = $block->toHtml(); $data['cart_header'] = $html; $block = $this->getLayout()->createBlock('checkout/cart'); $block->setTemplate('checkout/cart-ajax.phtml') ->addItemRender('simple','checkout/cart_item_renderer','checkout/cart/item/default.phtml') ->addItemRender('grouped','checkout/cart_item_renderer_grouped','checkout/cart/item/default.phtml') ->addItemRender('configurable','checkout/cart_item_renderer_configurable','checkout/cart/item/default.phtml'); $html = $block->toHtml(); $data['big_cart'] = $html; $cart = Mage::getModel('checkout/cart')->getQuote()->getData(); $qty = $cart['items_qty']; $data['cart_header_cnt_text'] = $this->__('Shopping Cart') . ' (' . $qty . ')'; echo json_encode($data); }
3. delete retun url fix function :
/** * Delete shoping cart item action */ public function deleteAction() { $id = (int) $this->getRequest()->getParam('id'); if ($id) { try { $this->_getCart()->removeItem($id) ->save(); } catch (Exception $e) { $this->_getSession()->addError($this->__('Cannot remove the item.')); var_dump($e->getMessage()); exit(); } } $last_list_url = $_SERVER['HTTP_REFERER']; header('Location: ' . $last_list_url); $_SESSION['last_list_url'] = $last_list_url; exit(); //$this->_redirectReferer(Mage::getUrl('*/*')); }
相关推荐
$item->qty . ' - ' . $item->price . PHP_EOL; } ``` #### 4.3 更新购物车 更新购物车项的数量或属性,可以使用`update()`方法: ```php $itemId = 1; $newQuantity = 3; Cart::update($itemId, $newQuantity); `...
boolean add(CartItem item) //boolean值如果是false,表示 已经购买过该商品。 void delete(long id) //删除某个商品。id是产品的ID号。 void modify(long id,int qty) //修改商品的数量 double sum() //计价...
<?php } // display qty and button ?> <!--eof Add to Cart Box--> 替 换到你的模板下的tpl_product_info_display.php里头对应的<!--bof Add to Cart Box -->...<!--eof Add to Cart Box-->就行.弄好这个文件之后...
and (item_no not in (select item_no from base_warehouse_qty where branch_no='0001') or item_no in(select item_no from base_warehouse_qty where branch_no='0001' and isnull(batch_no,'')='')) update a ...
grant delete, update(qty) on SPJ to Tom 〔4〕把对用户 Tom 授予的所有权力收回: revoke delete, update(qty) on SPJ from Tom revoke insert on S from Tom cascade 〔5〕对用户 Mary 增加 SPJ 表的 SELECT ...
SELECT SUM(QTY) FROM BOOK WHERE INTIME BETWEEN TO_DATE('2005/12/15 18:21:08', 'YYYY/MM/DD HH24:MI:SS') AND TO_DATE('2006/02/23 19:00:00', 'YYYY/MM/DD HH24:MI:SS') 该语句将查询 2005 年 12 月 15 日 18 ...
where Sno='s5' and Jno='J4' and Pno='p6' 10. 在 SPJ 表中新增一名为 SDATE 的列 alter table SPJ add SDATE datetime 知识点: * SQL 数据更新语句的基本语法格式 * 单个元组及多个元组的插入、修改及删除...
SELECT ItemNumber, Qty FROM OrderDetails FOR XML RAW('item'), ROOT('items'); ``` #### 步骤二:在存储过程中解析XML 一旦XML变量传递到了存储过程,就需要将它解析并转化为可以操作的数据结构。这里可以通过...
Update SALES Set qty = 50 WHERE qty Update SALES Set qty = 60 WHERE qty COMMIT TRANSACTION B COMMIT TRANSACTION A ``` - A、SALES表中qty列最小值大于等于30 - B、SALES表中qty列最小值大于等于40 - C、...
UPDATE co_ship SET (qty_invoiced, amount) = (SELECT qty_invoiced, qty_issued FROM co_line WHERE co_line.co_num = co_ship.co_num AND co_line.line_num = co_ship.co_line_num AND co_line.qty_returned <> ...
Update SALES Set qty = 50 WHERE qty Update SALES Set qty = 60 WHERE qty COMMIT TRANSACTION B COMMIT TRANSACTION A ``` - **选项D:** `SALES`表中`qty`列最小值大于等于60 **解释:** 上述代码示例展示了...
$query = "UPDATE $table SET quantity='$quantity' WHERE session='$session' AND "; $query .= "product='$product' "; mysql_query($query); } } function delete_item($table, $session, $product) ...
Update SALES Set qty=50 WHERE qty Update SALES Set qty=60 WHERE qty COMMIT TRANSACTION B COMMIT TRANSACTION A ``` - **选项 A:** SALES表中qty列最小值大于等于30 - **选项 B:** SALES表中qty列最小值大于...
7. 将供应商 s2 为“一汽”工程项目所供应的零件数量修改为 2000:UPDATE SPJ SET QTY=2000 WHERE SNO='2' AND JNO=(SELECT JNO FROM J WHERE JNAME='一汽'); 8. 将全部红色零件的颜色修改为浅红色:UPDATE P SET ...
script src =" components/qty/min/qty.min.js " > </ script > nodejs或iojs $ npm install --save qty var Qty = require ( 'qty' ) ; // ... 支持(可选) 添加对angular-qty.js引用 < script ...
UPDATE order_rollup SET (qty, price) = (SELECT SUM(qty), SUM(price) FROM order_lines WHERE customer_id = 'KOHL') WHERE cust_id = 'KOHL' AND order_period = TO_DATE('01-Oct-2000'); ``` 在这个例子中,`...
update a set a.up_end=up*@zk/100,a.dis_cnt=@zk,a.amtn=up*@zk/100*qty/1.17,a.amt=up*@zk/100*qty, a.tax=up*@zk/100*qty/1.17*0.17 from tf_pos a left join tf_pos_z b on a.os_no=b.os_no where a.os_no=@os_...
WHERE cust_id='KOHL' AND order_period=TO_DATE('01-Oct-2000'); ``` 3. DELETE语句用于从表格中删除行。例如: ```sql DELETE FROM po_lines WHERE ship_to_state IN ('TX','NY','IL') AND order_date = 'some_...
UPDATE order_rollup SET (qty, price) = (SELECT SUM(qty), SUM(price) FROM order_lines WHERE customer_id = 'KOHL' AND order_period = TO_DATE('01-Oct-2000')); ``` - DELETE:从表中删除数据。DELETE 语句...