2012-07-17 48 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