2012-07-17 69 views
0

我使用Joomla 1.5的擴展Virtuemart 1.1.9來創建我的購物車。在另一個組件的幫助下,我可以使用產品ID和數量將純文本文件上傳到服務器。按照下面的程序,我可以將貨物裝入購物車。數據庫中的Virtuemart購物車字符串結構

此方法的問題是,當我繼續下訂單時,產品價格不會與訂購數量相乘以獲得訂單總額。

任何想法?

這裏是代碼

DECLARE done INT DEFAULT 0; 
declare producto, cantidad, cliente, carga, categoria int; 
declare cantidadreg, cuenta, i int default 0; 
declare cadena text default ""; 
declare varcarga int default 0; 

declare cur1 cursor for select jos_vm_product.product_id, cant_producto, id_cliente, datos_cargas_vm.id_carga, category_id 
from datos_cargas_vm inner join cargas_vm on datos_cargas_vm.id_carga=cargas_vm.id_carga 
inner join jos_vm_product on datos_cargas_vm.id_producto=jos_vm_product.product_sku 
inner join jos_vm_product_category_xref on jos_vm_product.product_id = jos_vm_product_category_xref.product_id 
where estado_carga='P' 
order by datos_cargas_vm.id_carga, jos_vm_product.product_id; 

declare continue handler for not found set done = true; 

open cur1; 

read_loop: LOOP 
    fetch cur1 into producto, cantidad, cliente, carga, categoria; 

    if done then 
     leave read_loop; 
    end if; 

    if varcarga!=carga then 
     select count(*) into cantidadreg from datos_cargas_vm inner join cargas_vm on datos_cargas_vm.id_carga=cargas_vm.id_carga 
     inner join jos_vm_product on datos_cargas_vm.id_producto=jos_vm_product.product_sku 
     inner join jos_vm_product_category_xref on jos_vm_product.product_id = jos_vm_product_category_xref.product_id 
     where estado_carga='P' and datos_cargas_vm.id_carga=carga; 

     set varcarga:=carga; 
     set cadena:=concat("a:",cast(cantidadreg+1 as char),":{s:3:\"idx\";i:",cast(cantidadreg as char),";"); 
     set i:=0; 
    end if; 

    set cadena:=concat(cadena,"i:",cast(i as char),";a:5:{s:8:\"quantity\";i:",cast(cantidad as char), 
     ";s:10:\"product_id\";s:5:\"",cast(producto as char),"\";s:9:\"parent_id\";i:",cast(producto as char), 
     ";s:11:\"category_id\";i:",cast(categoria as char),";s:11:\"description\";s:0:\"\";}"); 
    set i:=i+1; 

    if i=cantidadreg then 
     set cadena:=concat(cadena,"}"); 
     -- select cantidadreg,cadena; 

     select count(*) into cantidadreg from jos_vm_cart where user_id = cliente; 

     if cantidadreg=0 then 
      insert into jos_vm_cart(user_id,cart_content) values(cliente,cadena); 
     else 
      update jos_vm_cart set cart_content=cadena where user_id=cliente; 
     end if; 
     update cargas_vm set estado_carga='C' where id_carga=carga; 
    end if; 
END LOOP; 

close cur1; 

回答

0

如果你要繞過所有的virtuemart邏輯裝載車,你可能將不得不效仿,並在同一時間做數學題負載。

+0

好客,並部分解決它 – 2013-04-30 19:09:13

相關問題