Giter Club home page Giter Club logo

cart's People

Contributors

faisuc avatar fulopattila122 avatar justrau avatar stylecibot 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cart's Issues

Propose to add functionality for ordering Service-based Products

Why add this ?

The current addItem() combines quantity for same product, that works perfectly well for normal physical products. However, when it comes to service-based products with customisations, it is often different for each item.

e.g. A sticker printing company sells 10x10cm label sticker as a product but every order and item is considered unique because the print design is different. It wouldn't make sense to add millions of product since there's practically no limit to people's designs.

This would add the functionality of Cart::addServiceItem() where it allows the cart to store individual entries. So the customer can order 10x10cm label with multiple designs.

This applies to service oriented (built-to-order) industries / businesses:

  • Printing
  • Signmaking
  • Accounting
  • Secretarial
  • Law
  • etc

The codes

Vanilo\Cart\CartManager.php

/**
 * @inheritDoc
 */
public function addServiceItem(Buyable $product, $qty = 1, $params = []): CartItem
{
    $cart = $this->findOrCreateCart();

    return $cart->addServiceItem($product, $qty, $params);
}

Vanilo\Cart\Models\Cart.php

/**
 * @inheritDoc
 */
public function addServiceItem(Buyable $product, $qty = 1, $params = []): \Vanilo\Cart\Contracts\CartItem
{
    $item = $this->items()->create(
        array_merge(
            $this->getDefaultCartItemAttributes($product, $qty),
            $this->getExtraProductMergeAttributes($product),
            $params['attributes'] ?? []
        )
    );
    
    $this->load('items');

    return $item;
}

Cart not remember when preserve_for_user + merge_duplicates is used

My cart keeps disappearing when i use both settings in the vanilo.php config file. When i remove one of the setting (and use php artisan cache:clear) the cart is remembered. For example i've removed merge_duplicated and i can see the cart in the database table.

I am using version 1.1.1 of vanilo.

I'm using a config file with this content:

<?php
return [
    'cart' => [

        /*
         * @see https://github.com/vanilophp/cart#preserve-the-cart-for-users-across-logins
         */
        'preserve_for_user' => true,
        'merge_duplicates' => true,
    ]
];

How to Update cart item quantity

So I've implemented using the cart library in my project but i can't seem to be able to update a cart item's quantity. How do I do that?

Configurable Table Name for Cart Model

Currently Vanilo assumes that the table name is carts, and there is no way to configure this. Can you make this a config setting, please?

I'll try to submit a pull request.

Resources not being published

Hi

The migrations and config file is not published when running php artisan vendor:publish when only this package is being installed instead of whole framework.

Request: addItem > always save extra attributes

For each product i've got a seperate 'product_remarks' field which can be filled before adding the buyable product to the cart. This field can contain 'custom information' about the product and it should be possible to edit this field.

The first time i add a product to the cart this attribute is saved properly. However the second time it is ignored. This can be traced to the if in: src\Models\Cart.php > addItem()

To be clear, i'm not using this attribute to copy existing buyable model attributes, but to add a custom attribute. Is it possible to implement something like this?

All item from different carts shown as user's cart

If I open /shop uri or product page, Cart::getItems() return all items from database that belongs to different carts and users. On other pages everything works fine.

dd(Cart::model()) on /shop uri show this
#relations: array:2 [▼
"user" => User {#722 ▶}
"items" => Collection {#713 ▼
#items: array:4 [▶]
}
]

on any other page:
#relations: []

And ideas why?

Private methods in Vanilo\Cart\Models\Cart

Vanilo Cart 0.5.1

I have a special type of product in database for which I need to insert the product into the cart from the product.show page as new item not to update the quantity every time I insert it like it is standard for inserting the same product. Therefore, I have extended the Cart model to modify the addItem(Buyable $product, $qty = 1, $params = []). The only issue that I had implementing it that there are two methods that are private in the Vanilo\Cart\Models\Cart

getDefaultCartItemAttributes(Buyable $product, $qty)
getExtraProductMergeAttributes(Buyable $product)

I just had to copy and paste them around from the parent class. Do you have a particular reason these methods are private please? Is it possible that the methods can be protected instead? Thank you for help.

Instructions for Permanent Extra Fields

Hi, I'm trying to use the instructions for the Permanent Extra Fields, but it references a config file (config/vanilo.php) that I don't have. I'm only using the Cart module, not the framework - is this not doable in that context?

Empty cart after page refresh.

I'm implementing a custom Buyable Model but after successfully adding to Cart, cart count returns the correct values but after page refresh cart count goes back to zero.

Additional parameters passed in addItem are not being saved

Environment: Laravel 5.5.39
Standalone: vanila/cart: 0.2

Code:

$product = \App\Models\Banner::find(1);
\Cart::addItem($product, 1, ['width' => 123, 'height' => 12]);

There is no column in the cart_item table to store the additional parameters.

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.