试图(基于自定义选择价格更新)创建的苹果像购物车页面 [英] attempt to create apple like shopping cart page (price updates based on customization selections)

查看:83
本文介绍了试图(基于自定义选择价格更新)创建的苹果像购物车页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让那里的基础上每个选择价格更新,您在此页面上看到一车页面 http://store.apple.com/us_smb_78313/configure/MC915LL/A ?MCO = MTk4Mjc2MDA

i am trying to make a cart page where based on each selection the price updates as you see on this page http://store.apple.com/us_smb_78313/configure/MC915LL/A?mco=MTk4Mjc2MDA

如果发现苹果页面,每个无线电字段值有若干像095-344上,该值是一些如何通过AJAX发送到服务器端谁然后​​接收一个价值被添加到购物车中作为总那被认为。

if you notice on the apple page that each radio fields value has a number like 095-344 and this value is some how sent via ajax to a serverside who then receives a price value to be added to the cart as a total that is viewed.

我创建了类似的这里是链接的东西。 http://69.231.228.101:8888/demo/

i created something similar here is the link. http://69.231.228.101:8888/demo/

我已经只有前两个领域的工作,这是数量和类型。当页面加载的第三个选择是自动选择,并显示其价格。和时,选择部选择的项目的值被累积到已存在于右上的值。有问题即时通讯是,如果你现在再次选择了量变到质变的数量,你想,而不是价值重置做正确的数学量。我究竟做错了什么?

i have made only the first two fields to work which is quantity and type. when the page loads the 3rd option is auto selected and its price is displayed. and when the section select is selected the items value is accumulated to the value that already exists in the upper right. the problem im having is if you now select the quantity again to change the amount of quantity you wanted the value resets instead of do the right math. what am i doing wrong?

另外,你会知道一个jQuery网站或一些网站已尝试这一点,我可以学习的?我已经看过漫长而艰难的,并不能找到这种创造的东西。我只是看到一堆简单的购物车页面的计算并没有什么像什么即时寻找。网站的很多有这样的事情,即时通讯寻找,例如苹果,戴尔,惠普,进行产品定制和价格更新,根据您的选择。什么即时知道如何以及在哪里他们学习如何做到这一点。必须有一个网站,教它。

plus, would you know of a jquery site or some site that has attempted this that i can study? i have looked long and hard and cannot find anything of this kind created. i just see a bunch of simple cart calculation pages and nothing like what im looking for. alot of sites have something like this that im looking for for example apple, dell, hp, for product customizations and the price updates based on your selection. what im wondering how and where did they learn how to do it. there must be a site that teaches it.

感谢

推荐答案

好确定。试试这个:把你的表单并提交。 (如果你不这样做的话,这样做)与阿贾克斯(看<一href="http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/"相对=nofollow>这个)。这样,每一个检查无线电提交。下面以每个无线电和检查他的价值增加了​​一个变量 $ priceNUM 合适的价格值。在结束从每一个检查无线电增加每一个价格一起,成为一个 $共 var和输出。 这是一个愚蠢的例子。

Well ok. Try this: Take your form and submit it. (If you weren't doing it then, do it) with ajax (Look at this). In this way every checked radio is submitted. Now take each radio and check his value adding to a variable $priceNUM the right price value. At the end add every single price from every single checked radio together, into a $total var and output that. Here's a stupid example.

HTML

<form>
 <input type="radio" name="box1" value="01"/>
 <input type="radio" name="box1" value="03"/>
 <input type="radio" name="box1" value="03"/>

 <input type="radio" name="box2" value="01"/>
 <input type="radio" name="box2" value="03"/>
 <input type="radio" name="box2" value="03"/>

 <input type="radio" name="box3" value="01"/>
 <input type="radio" name="box3" value="03"/>
 <input type="radio" name="box3" value="03"/>
</form>

PHP

<?php

# Requiring vars
$box1 = $_POST['box1'];
$box2 = $_POST['box2'];
$box3 = $_POST['box3'];

# Checking
if (empty($box1) or empty($box2) or empty($box3)) { /* Error, or $price = 0 */ }

switch ($box1) 
{
 case '01':
  $price1 = 10;
 break;

 case '02':
  $price1 = 20;
 break;

 case '03':
  $price1 = 30;
 break;

 default:
  $price1 = 0;
 break;
}

switch ($box2) 
{
 case '01':
  $price2 = 50;
 break;

 case '02':
  $price2 = 100;
 break;

 case '03':
  $price2 = 150;
 break;

 default:
  $price2 = 0;
 break;
}

switch ($box3) 
{
 case '01':
  $price3 = 2;
 break;

 case '02':
  $price3 = 4;
 break;

 case '03':
  $price3 = 6;
 break;

 default:
  $price3 = 0;
 break;
}

$total = $price1 + $price2 + $price3;
echo $total;

?>

现在使用jQuery做,当盒子被改变的形式提交(我想你已经知道如何做到这一点),我们正在做。

Now with jquery make the form to submit when a box is changed (i think you already know how to do this) and we are done.

其实每次它发生的时候,我们要计算总,但它是最简单的方法。你也可以做一些与数据库或cookies,但它变得太复杂了。

Actually every time it happens, we are going to calculate the total, but it is the easiest way. You could also make something with a database or with cookies but it became too complicated.

这篇关于试图(基于自定义选择价格更新)创建的苹果像购物车页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆