wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 489 forks source link

Multiple prices in SimpleCartJs Shelf #521

Open fstodulski opened 8 years ago

fstodulski commented 8 years ago

Hi, I have a problem. I 'm coding some website using AngularJs. I want to display my product, which is in meny prices. The price depends on size. So, for example I have a bucket of wings ( KFC ) in meny sizes.

This is my code:

<div class="product-content white-bg simpleCart_shelfItem" toggleClass ng-repeat="product in products">
    <div class="col-sm-7 col-xs-7">
        <div class="product-description">
            <p class="hidden">{{'{{product.id}}'}}</p>
            <h5 class="product-name pull-left item_name">{{'{{product.name}}'}}</h5>
            <p class="pull-left prod_desc">{{'{{product.description}}'}}</p>
            <p class="hidden">{{'{{product.category }}'}}</p>
        </div>

        <div class="add-product-container">
            <select class="select-product-type item_size white-bg  f-w-100" name="" id="">
                <option value="{{'{{p.price}}'}}" ng-repeat="p in product.options" class="text-center item_price">{{'{{p.price}}'}}</option>
            </select>

            <div class="actions">
                <a class="item_add" href="javascript:;">
                    <button class="action add-product green-bg"><i class="fa fa-plus" aria-hidden="true"></i></button>
                </a>
            </div>

        </div>
    </div>
    <div class="col-sm-5 col-xs-5 product-photo">
        <img src="{{ '{{product.photo}}'}}" alt="">
    </div>

</div>

The thing is, that - after adding new product to the cart script adds the whole option value for ex.

in the cart it views 2448,0 instead of seperate 24 and 48.

Again, I use Angular Js to display my JSON data. SimpleCart works okey with names and quantity but it doesnt work with prices.

Any ideas how to do it?

fstodulski commented 8 years ago

Nevermind i found a solution

<select class="item_price">
<option value="2.00">1 clip</option>
<option value="3.00">2 clips</option>
<option value="3.50">1 pince</option>
<option value="5.00">2 pinces</option>
</select>