我正在使用Joomla的扩展程序Virtuemart 1.1.9和joomla 1.5来创建我的购物车。在另一个组件的帮助下,我可以使用产品ID和数量将纯文本文件上传到服务器。通过以下程序,我可以将负载固定在购物车中。
这种方法的问题在于,当我继续下订单时,产品价格不会与订购数量相乘以获得订单总数。
有什么想法吗?
这是代码
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 :(得分:0)
如果您要绕过所有的virtmart逻辑加载购物车,您可能需要模拟它并在加载的同时进行数学运算。