Code Monkey home page Code Monkey logo

cart's People

Contributors

bloom-design avatar chrisnharvey avatar nethask avatar zot24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cart's Issues

setIdentifier

Hi Guys,

When setting the Cart::identifier('test123'); I was under the impression that I would rename the identifier that was generated or move the cart contents over into it?

Seems it just creates a empty array under a cart session variable...

What am I missing here?

Thanks

Make variable names less confusing

The variable names for $id and $identifier can be confusing. In the cart we should use $itemIdentifier for item identifiers to prevent confusion between the cart identifier.

Cart content storage after sesison

Hi,
i ask you if it's possibile make something like cookie::forever of Laravel.
The point is, and i ask you some days ago, i need to stay saved somewehere the cart content for a not logged user. So now moltin cart package works only with Session, so when i close browser and reload page the cart is empty.
I need to use another cookie to maintain alive the content ?

Coupon Functionality

One thing that I'm in desperate need for is a Coupon functionality ... To be able to use a coupon to give a overall cart (or even product specific) discount.

What are your thoughts?

Cart not available on new requests

Seems after a new request not any of the Cart::method() seems to be working.
However when i dump sessions then i see cart value in there.

@foreach( Cart::contents(true) as $item )
{{ print_r($item) }}
@Endforeach

Does nothing, should output all the contents

@if(Cart::totalItems())

{{ Cart::totalItems() }} in cart


@endif

Does nothing either.
Keep in mind this is blade syntax, however the package seems not to work.

This is however the output from sessions

Array ( [_sf2_attributes] => Array ( [_token] => 27TqPweZAfKCtYCEhMZlP6YSYCKi1R1iLlLByeFM [cart] => Array ( [10a60423601f1e90ec6721796e3a1932] => Array ( ) [15a28e729264ee3f3050c238bea1311a] => Array ( [8a48aa7c8e5202841ddaf767bb4d10da] => Moltin\Cart\Item Object ( [identifier:protected] => 8a48aa7c8e5202841ddaf767bb4d10da [store:protected] => Moltin\Cart\Storage\LaravelSession Object ( [identifier:protected] => [id] => 15a28e729264ee3f3050c238bea1311a ) [tax:protected] => Moltin\Tax\Tax Object ( [percentage:protected] => 0 [deductModifier:protected] => 1 [addModifier:protected] => 1 ) [data:protected] => Array ( [id] => 6 [name] => Battery - Lithium CR2025 [price] => 1 [quantity] => 3 ) ) ) ) [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) ) [_sf2_flashes] => Array ( ) [_sf2_meta] => Array ( [u] => 1375124033 [c] => 1375121483 [l] => 7200 ) ) 1

So the content is definately there.

Stock and Add to Cart

How can I use this package so that when an item is added to the cart it checks the stock level and if is set to 1 or below, if the customer goes back and tries to order another of the same item it knows that it already exists and that there is only one of them?

Any idea's?

Using remove();

If i have 3 products in the cart and use remove(); on a Laravel route to remove an item to then redirect back it shows that the session has been destroyed.

Why is this? Or am I doing something wrong?

Version 1?

Hey there, this package is great ... do you feel it's ready for primetime? And when will the official production release be available?

Recalculate Tax after item as been added to the cart

I have not been able to figure this out. Once an item is in the cart I cannot change its tax percentage for calculation. I may be missing something, but I have struggled for a couple hours to figure it out. When attempting to change tax for the item the tax property changes successfully, but the tax is calculated based on when I originally added the item. Any thoughts?

Thanks!

Awesome cart BTW, start of something good for sure!

Identifier

Hi,

Just wondering if you could provide some more information on access the $identifier.

Cart::has($itemIdentifier);
Cart::item($itemIdentifier);
Cart::remove($itemIdentifier);

What I'm not getting is how am I suppose the know the $identifier when all I know is the item id.

Could you please provide some sample uses.

Many thanks.

Issues installing via Composer

Hi,

I'm struggling to install your cart package via composer - every time I try, I get the error:

Problem 1
    - Installation request for moltin/cart dev-master -> satisfiable by moltin/cart[dev-master].
    - moltin/cart dev-master requires moltin/tax dev-master -> no matching package found.

and here is my composer.json:

{
    "require" : {
        "moltin/cart": "dev-master"
    }
}

Any help would be much appreciated.
Thanks

Can't get item by its identifier

I can´t get an item by its ID,
I'm trying to remove it from the cart but I obtain:

Call to a member function toArray() on a non-object

I can reproduce the issue like this:

foreach (Cart::contents() as $item) {
    \Log::info ('ID: '. $item->id); // Outputs "42" (integer)
    \Log::info ('Item', Cart::item ($item->id)->toArray ()); // error
}

Also I can't remove the item using

Cart::item((string) $id)->remove()

Product ID with Different Size and Price value

Hi

Am having the product with different size and different price values. How to show it in the basket. I tried but it shows single ID with all value appended it to it. But I need to show each individual product with different size and price amount. Kindly suggest me how to do that.

For example,

Am having a product called Shirt, Each shirt have sizes like L, M, XL and each varies based on the size. Suppose if the user ordered L and M size shirt mean it will show only one shirt with all values not as separate shirt with different size and price.

Please help to solve this issue.

Adding multiple of the same item

I'm assuming that the "id" attribute for a cart item represents the Cart id? At first I thought it was supposed to be the product id as a database reference, but I cannot add multiple items with the same "id".

Again, I'll reference the Cartify project here on GitHub ... the "id" for each Cart item was automatically generated, which allowed you to add multiple of the same product, which had a direct impact on the "quantity" field... the quantity was automatically handled, and if all of the attributes of an add product was the same as another that exists in the cart, the quantity was automatically added to... otherwise, it was a new item in the Cart.

Does that make sense?

Qty and not showing more than 1 item in table

I have the following which adds to the cart:

      {{ Form::open(['route' => 'cart']) }}
                <input type="hidden" name="path" value="{{ Request::path() }}">
                <input type="hidden" name="image" value="{{ $item->image }}">
                <input type="hidden" name="product" value="{{ $item->name }}">
                <input type="hidden" name="description" value="{{ $item->seo_description }}">
                <input type="hidden" name="qty" value="1">
                <input type="hidden" name="size" value="{{ Session::get('size') }}">
                <input type="hidden" name="colour" value="{{ Session::get('colour') }}">
                <input type="hidden" name="price" value="{{ $item->price }}">
            @if ($item->stock > 0) <button class="btn btn-success">Add to Bag</button>  @else <a href="" class="btn btn-primary">Email us</a> @endif
            {{ Form::close() }}

Then I have this which shows the items of the carts.

  @foreach($items as $item)
                    <tr>
                        <td class="col-sm-8 col-md-6">
                        <div class="media">
                            <span class="thumbnail pull-left"> <img class="media-object" src="/uploads/product-images/{{$item->image}}" style="width: 72px; height: 72px;"> </span>
                            <div class="media-body">
                                <h4 class="media-heading"><a href="{{ $item->path }}">{{ $item->name }}</a></h4>
                                <span>Status: </span><span class="text-success"><strong>In Stock</strong></span>
                            </div>
                        </div></td>
                        <td class="col-sm-1 col-md-1" style="text-align: center">
                        <input type="email" class="form-control" id="exampleInputEmail1" value="1">
                        </td>
                        <td class="col-sm-1 col-md-1 text-center"><strong>&pound;{{ $item->price }}</strong></td>
                        <td class="col-sm-1 col-md-1">
                        </td>
                    </tr>
                    @endforeach
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td><h5>Subtotal</h5></td>
                        <td class="text-right"><h5><strong>&pound;{{ $item->price }}</strong></h5></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td><h3>Total</h3></td>
                        <td class="text-right"><h3><strong>&pound;{{ Cart::total(false) }}</strong></h3></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td><a href="/remove/{{ $item->identifier }}" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Remove</a>
Continue Shopping Checkout

But like I said it only shows one item, but yet the amount in £ is correct.
Show what should I be doing? Or what am I doing wrong?

Also a suggestion would be to update the docs a little more with more info like this to show people like me more examples.

Example code

Hello i have implement this class with no success.
Here my code, no errors, no warnings, only blank screen.

require_once('vendor/autoload.php');

use Moltin\Cart\Cart;
use Moltin\Cart\Storage\Session;
use Moltin\Cart\Identifier\Cookie;

function shopping_items()
{
    $cart = shopping_getCart();
    $cartItems = $cart->contents();
    $d = '';
    if (count($cartItems) > 0) {
        foreach ($cartItems as $item) {
            $d .= "<li>{$item->name} {$item->quantity}x{$item->price}</li>";
        }
    }
    return "<ul>$d</ul>";
}

function shopping_getCart()
{
    return  new Cart(new Session, new Cookie);
}

function shopping_add_item()
{

    $cart = shopping_getCart();
    $cart->insert(array(
    'id'       => 'foo',
    'name'     => 'bar',
    'price'    => 100,
    'quantity' => 1
));
}

shopping_add_item();
echo shopping_items();

Methods that take id may fail if item has options

Methods that take an id (has, item etc) should take the identifier, not the user-defined id. The reason for this is because there can be multiple items with the same id, but with different product options.

Accessing the Cart throughout application

This isn't really an "issue" per-say, but I do think it should be outlined in your documentation...

What is the best way to reference the cart throughout an application? For example, in Laravel, if I want to pull up the Cart within a Route, what's the recommended way of getting the Cart object?

Have you thought about adding a static method? Check out Cartify: https://github.com/brunogaspar/cartify

Cartify::cart()->total_items() is an example of how the static methods can be called from anywhere in the app.

Adding multiple items, saving to db

I'm having an issue (or me not understanding) how to to save more than one item to my database.

If i die and dump Cart::contents() i get the following: which shows two items.

      protected 'addModifier' => int 1
      protected 'data' => 
        array (size=11)
          'id' => string '100' (length=3)
          'name' => string 'Beautiful Evening Dress' (length=23)
          'price' => string '35.00' (length=5)
          'quantity' => string '1' (length=1)
          'image' => string 'dtTCkLMT3C7lrYE6b1afd6H1hH5IyJ6hYnPWhQbHwkGgCIfhmaTsP9kUhxUr.jpg' (length=64)
          'path' => string 'category/new-in' (length=15)
          'description' => string 'Beautiful Evening Dress ' (length=24)
          'stock' => string '0' (length=1)
          'delivery' => string '3.99' (length=4)
          'colour' => string 'Black' (length=5)
          'size' => string '22' (length=2)
  '6de83ad2f06a80ee5b06ead51cb74fb5' => 
    object(Moltin\Cart\Item)[137]
      protected 'identifier' => string '6de83ad2f06a80ee5b06ead51cb74fb5' (length=32)
      protected 'store' => 
        object(Moltin\Cart\Storage\LaravelSession)[138]
          protected 'identifier' => null
          public 'id' => string '66f7ef23c389dcafb9394506a5b5d934' (length=32)
      protected 'tax' => 
        object(Moltin\Tax\Tax)[139]
          protected 'percentage' => int 0
          protected 'deductModifier' => int 1
          protected 'addModifier' => int 1
      protected 'data' => 
        array (size=11)
          'id' => string '53' (length=2)
          'name' => string 'Black and Silver Pattern dress with Sequins ' (length=44)
          'price' => string '25.00' (length=5)
          'quantity' => string '1' (length=1)
          'image' => string 'USoWtjCsby50.jpg' (length=16)
          'path' => string 'category/new-in' (length=15)
          'description' => string 'Black and Silver Pattern dress with Sequins ' (length=44)
          'stock' => string '1' (length=1)
          'delivery' => string '3.99' (length=4)
          'colour' => string 'Patterned' (length=9)
          'size' => string '14' (length=2)

So the question is, how do i save these items to the DB?

@jHoldroyd @AJSturrock @outrunthewolf

Add ability to add custom cart data

Currently it is possible to add any custom data to an item, but I think we need to allow the ability to add custom data to the entire cart object. This would be useful for setting the coupon code that is applied to the cart, or some other useful data.

hasOptions

Hi,

Using this package i want to grab the options from the Cart:insert method.

How would this be done?

I tried $item->options()->first_option but fails.

Inserting over a product in the cart.

Using session, let's say we have:

$A = ["id" => "example", "quantity" => 5, ...];
// and
$B = ["id" => "example", "quantity" => 11, ...];

If we Cart::insert($A) we see from Cart::contents(true) that we have a quantity of 5.

However, using this same cart - if we Cart::insert($B) then examine the contents we see that we have a quantity of 11 until the script ends. At this point the quantity is once again 5 and the new information is not stored.

If this information were stored (not sure if intentional) then item updates would be much simpler in many cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.