A developer-friendly e-commerce foundation for your Laravel app

Overview

laravel-shopr

A developer-friendly e-commerce foundation for your Laravel app. All the features you need for your webshop but without sacrificing you as a developer. Full documentation here: https://laravel-shopr.happypixels.se

Some of the features included:

  • Shopping cart
  • Discount coupons
  • Any model can be shoppable
  • SCA-ready checkout process with payment solutions out of the box
  • Cart to Order conversion
  • Automated order emails to the customer and administrators
  • A simple REST API for managing the cart and checkout
  • And more

Documentation

Full documentation: https://laravel-shopr.happypixels.se
Demo application: https://github.com/happypixels/laravel-shopr-demo

Requirements

  • PHP 7.1+
  • Laravel 5.5+
  • MySQL 5.7+

Installation

Install the package via Composer:

composer require happypixels/laravel-shopr

Publish and run the migrations:

php artisan vendor:publish --provider="Happypixels\Shopr\ShoprServiceProvider" --tag="migrations"
php artisan migrate

Publish and review the configuration:

php artisan vendor:publish --provider="Happypixels\Shopr\ShoprServiceProvider" --tag="config"

Optionally you may publish the views to make them modifiable:

php artisan vendor:publish --provider="Happypixels\Shopr\ShoprServiceProvider" --tag="views"

Optionally you may publish the translation files to make them modifiable:

php artisan vendor:publish --provider="Happypixels\Shopr\ShoprServiceProvider" --tag="translations"

After this, refer to the documentation to get started.

Contributing

Found a bug or have a feature request? Open an issue on Github.
Found a security-related issue? Please email [email protected].

Support me

If this package made your life a bit easier, consider buying me lunch once or twice a month through Patreon. All support helps me spend more time on packages like this and also comes with a few benefits šŸŽ Thanks!

Comments
  • Make it possible to customise money formatting

    Make it possible to customise money formatting

    First of all I want to say that working with laravel-shopr is an absolute delight, great job!

    Is your feature request related to a problem? Please describe. Currently you can specify your currency code in the ISO format, for instance, "DKK" (Danish Kr.), however, there is no way to change the formatting of this.

    Describe the solution you'd like It would be great to be able to format it as "kr" or whatever is possible with the money library you are using.

    This is just an example but in the money package that I currently use in my app, they expose this api in the config, perhaps inspiration could be drawn from there:

    'DKK' => [
            'name'                => 'Danish Krone',
            'code'                => 208,
            'precision'           => 0,
            'subunit'             => 100,
            'symbol'              => 'kr',
            'symbol_first'        => false,
            'decimal_mark'        => ',',
            'thousands_separator' => '.',
        ],
    

    What do you think?

    enhancement 
    opened by Reached 13
  • Adding support customizing models for custom implmentation options

    Adding support customizing models for custom implmentation options

    I'd like to extend the Order and OrderItem models with missing columns(notes, payment_url etc.) and use it in my own way. By leveraging the Application Container we can easily extend the base but leaving the cart -> order creation intact as is. Even the relationships will use the extended model

    Models can easily extend as such:

    class Order extends ShoprOrder {
    // adding more stuff onto it
    }
    
    class OrderItem extends ShoprOrderItem {
    // adding stuff
    }
    

    but don't forgot the configure the proper models:

    'models' => [
        'order' => App\Models\Order::class,
        'orderItem' => App\Models\OrderItem::class,
    ],
    

    And in case you only extend the Order class leave orderItem empty and it still works as it should.

    'models' => [
        'order' => App\Models\Order::class,
        'orderItem' => null,
    ],
    
    opened by yoramdelangen 5
  • Include the discounted amount on the $order

    Include the discounted amount on the $order

    I think for many shop-owners it would be really valuable to know if/when a discount has been given on an order, currently this info is not included in the $order object that is created in convertToOrder.

    Describe the solution you'd like Perhaps a nullable column "discounted_amount" on the orders table or a direct relation between the discounts and the order table (however I'm not sure about this approach).

    This is a minor thing obviously :) what do you think though?

    opened by Reached 3
  • Cart discounts is not applied to updated items

    Cart discounts is not applied to updated items

    Describe the bug Im trying to update items in the cart by making a call to the API like this

    window.axios.patch('/api/shopr/cart/items/' + item.id, {quantity: item.quantity}).then(response => {
          this.cart = response.data;
          console.log(this.cart);
    });
    

    This works fine, and it returns the cart summary (UI updates etc.), however it does not seem to take into account any discounts that have been applied already. I added a discount with a value of 50.00 as a percentage discount.

    Also I can confirm that the cart summary that comes back from the backend does not reflect the changes either. šŸ¤”

    Here is my full cart summary object for reference (don't mind the formatting):

    {  
       "items":[  
          {  
             "id":"15497087885c5eadf485ce3",
             "quantity":4,
             "shoppableType":"App\\Product",
             "shoppableId":1,
             "shoppable":{  
                "id":1,
                "name":"Nice AirMax",
                "description":"This is the most amazing shoe you will ever see lol!",
                "featured_image":"https:\/\/c.static-nike.com\/a\/images\/t_PDP_1280_v1\/f_auto\/gorfwjchoasrrzr1fggt\/air-max-270-shoe-nnTrqDGR.jpg",
                "price":800,
                "created_at":null,
                "updated_at":null
             },
             "options":[  
    
             ],
             "subItems":[  
    
             ],
             "total":3200,
             "price":800,
             "price_formatted":"DKK\u00a0800.00"
          }
       ],
       "discounts":[  
          {  
             "id":"15497087935c5eadf961800",
             "quantity":1,
             "shoppableType":"Happypixels\\Shopr\\Models\\DiscountCoupon",
             "shoppableId":2,
             "shoppable":{  
                "id":2,
                "valid_from":"2019-02-08 15:42:34",
                "valid_until":"2019-05-08 15:42:34",
                "uses":8,
                "code":"NEWCODE",
                "description":null,
                "is_fixed":0,
                "value":"50.00",
                "lower_cart_limit":"0.00",
                "created_at":"2019-02-08 15:42:34",
                "updated_at":"2019-02-09 10:37:57",
                "deleted_at":null
             },
             "options":[  
    
             ],
             "subItems":[  
    
             ],
             "total":-400,
             "price":-400,
             "price_formatted":"-DKK\u00a0400.00"
          }
       ],
       "sub_total":2240,
       "sub_total_formatted":"DKK\u00a02,240.00",
       "tax_total":560,
       "tax_total_formatted":"DKK\u00a0560.00",
       "total":2800,
       "total_formatted":"DKK\u00a02,800.00",
       "count":4
    }
    

    Is this intended design perhaps?

    Expected behavior The cart total and subtotal should be updated and take discounts into account also.

    cart behavior

    opened by Reached 3
  • Call to undefined method Illuminate\Events\Dispatcher::fire()

    Call to undefined method Illuminate\Events\Dispatcher::fire()

    Describe the bug Call to undefined method Illuminate\Events\Dispatcher::fire()

    To Reproduce Add a item to cart using Laravel 5.8

    Additional context The fire method of the Illuminate\Events\Dispatcher class has been removed in Laravel 5.8. The document page recommend using dispatch instead.

    Screen Shot 2019-08-09 at 18 51 34

    opened by jenky 2
  • Validation error when applying a coupon

    Validation error when applying a coupon

    Describe the bug A clear and concise description of what the bug is.

    When trying to add a coupon code a 422 validation error is thrown.

    To Reproduce Steps to reproduce the behavior:

    1. Make sure your database contains a valid coupon
    2. Make an ajax post request to the "/api/shopr/cart/discounts" endpoint with a body of a code {code: 'somecode'}
    3. See 422 validation error in the console

    Might help My assumption is that the rules array is colliding with the custom rules array set in the configuration file, because I tried to override the original rules array in CartDiscountController.php $rules = ['required', 'string']; with my own implementation it worked:

    $request->validate([
                'code' => 'required|string'
            ]);
    

    instead of

    $rules = ['required', 'string'];
    

    But obviously this is not compatible with the custom rules šŸ¤”

    opened by Reached 2
  • Discount coupons

    Discount coupons

    A highly requested feature which I've wanted to implement since the beginning of Shopr is Discount coupons. This issue will serve as a gathering place for checklists and discussions for this feature.

    Database structure I figure we'll add another table and model to the package. I thought about letting each user build their own database design, but eventually landed in the fact that this package is meant to make it as easy as possible to get started with a web shop, while still allowing for flexibility. Most projects won't need to modify the discount functionality or design if we just think it through, and so they shouldn't have to think about how to structure their discount table.

    Validation Some projects may need the ability to add custom validation to make sure the applied discount code is valid according to rules beyond a timestamp, code validation and other default rules. We need to make this easily configurable and modifiable.

    Todo

    • [x] Database table and model
    • [x] REST endpoint for applying a code
    • [x] Validation, is the code valid?
    • [x] Flexibility so that everyone can add their own validation logics
    • [x] Inclusion in the order and confirmation emails
    • [ ] A good abstraction for applying discounts to each new payment provider
    • [x] Access applied discount coupons on the cart summary
    • [x] Translatable validation errors
    • [x] Tests
    opened by mattias-persson 2
  • Subtotal/Tax Calculations

    Subtotal/Tax Calculations

    Subtotal subtracts (wrong amount at that) tax from item price? Not sure if this a bug, or by design. When adding an item to the cart with a price of $100 and a tax rate of %10, the subtotal shows $90.91.

    1. Shouldn't the subtotal be the price of the item(s) in the cart? Qty 1 @ $100 is $100+tax
    2. Why is the tax coming up as $9.09 ($100 * 10% = $110)
    Subtotal = 100.00
    Tax      =  10.00
    =================
    Total    = 110.00
    

    Response Object

    shoppingCart:Object
    count:1
    discounts:Array[0]
    items:Array[1]
    sub_total:90.9090909090909
    sub_total_formatted:"$90.91"
    tax_total:9.090909090909092
    tax_total_formatted:"$9.09"
    total:100
    total_formatted:"$100.00"
    shoppingCartCount:1
    shoppingCartEmpty:false
    

    To Reproduce Steps to reproduce the behavior:

    1. Add item to cart
    let data = {
       'shoppable_type': 'App\\Model',
       'shoppable_id': product,
       'quantity': 1,
       'price': 100.00
    }
    this.$http.post('/api/shopr/cart/items',data)
    

    Expected behavior

    shoppingCart:Object
    count:1
    discounts:Array[0]
    items:Array[1]
    sub_total:100.00
    sub_total_formatted:"$100.00"
    tax_total:10.000
    tax_total_formatted:"$10.00"
    total:110
    total_formatted:"$110.00"
    shoppingCartCount:1
    shoppingCartEmpty:false
    

    Desktop (please complete the following information):

    • OS: MacOS 10.14.6
    • Browser: Chrome
    • Version: Version 75.0.3770.142

    Additional context

    Config file: shopr.php

    /*
     * The tax percentage.
     */
    
    'tax' => 10,
    
    opened by macmedia 1
  • Support Stripe Strong Customer Authentication (SCA)

    Support Stripe Strong Customer Authentication (SCA)

    On September 14 Strong Customer Authentication will be required for all EU customers. To prevent purchases from being declined, we need to implement support for this.

    opened by mattias-persson 1
  • Fix ICU version in TravisCI

    Fix ICU version in TravisCI

    Travis comes with an outdated ICU version, causing tests related to the money formatter to fail. This PR aims at solving the problem by manually installing a newer version of ICU on the Travis machines.

    opened by mattias-persson 1
  • Typecast amount before the currency format

    Typecast amount before the currency format

    Whenever I set any tax value the money formatting throws an InvalidArgumentException with Amount must be an integer(ish) value. Its is getting thrown from vendor/moneyphp/money/src/Money.php file within the Money class constructor.

    For example; tax => 21

    Total price includes tax = 70 meaning the tax exact amount is 12.148760330579 and subtotal will be 57.851239669421. When the money formatter does times 100 it is still not a valid INT.

    opened by yoramdelangen 1
  • Allows to configure routes

    Allows to configure routes

    Is your feature request related to a problem? Please describe. The route paths and middleware can't be configured atm.

    Describe the solution you'd like Update config to support route path and middleware similar to laravel/telescope

    opened by jenky 4
  • Facades for Cart and Coupons

    Facades for Cart and Coupons

    Is your feature request related to a problem? Please describe. We currently only support using the REST API for dealing with the cart. This may be insufficient for more complex shops where custom functionality needs to be combined with it.

    Describe the solution you'd like Implement facades and helper methods for managing the cart.

    Additional context Possibly also allow configuring whether the REST api should be enabled at all.

    Implement facade methods for

    • [x] Getting the cart summary
    • [x] Getting the current cart count
    • [x] Clearing the cart
    • [x] Adding a cart item
    • [x] Updating the quantity of a cart item
    • [x] Removing a cart item
    • [x] Applying a discount coupon
    enhancement 
    opened by mattias-persson 1
Releases(1.6.0)
Owner
Happy Pixels AB
We love building great mobile and web applications.
Happy Pixels AB
Antvel is an ecommerce project written in Laravel 5.* intended for building a friendly eStore either for startups or big companies.

Antvel is an ecommerce project written in Laravel 5.* intended for building a friendly eStore either for startups or big companies.

Antvel - Official 650 Dec 28, 2022
Zen CartĀ® is a full-function e-commerce application for your website.

Zen CartĀ® - The Art of E-Commerce Zen CartĀ® was the first Open Source e-Commerce web application to be fully PA-DSS Certified. Zen CartĀ® v1.5.8 is an

Zen Cart 304 Jan 6, 2023
Commerce GrappQL Package for Laravel

Sailwork Commerce Package for Laravel Document Please read document in here: Document Installation You can install the package via composer: composer

Sail Work 6 May 10, 2021
Laravel FREE E-Commerce Software

Laravel FREE E-Commerce Software

Jeff Simons Decena 1.7k Dec 24, 2022
A free open source e-commerce platform for online merchants based on customised version of Laravel.

A free open source e-commerce platform for online merchants based on customised version of Laravel.

Ace Vinayak 58 Oct 19, 2022
Integrated online shop based on Laravel LTS and the Aimeos e-commerce framework

ā­ Star us on GitHub ā€” it motivates us a lot! ?? Aimeos Laravel ecommerce platform Aimeos is THE professional, full-featured and high performance e-com

Aimeos 3k Jan 5, 2023
E-Commerce Laravel Project

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Mohamed Fadl 2 Dec 10, 2022
A e-commerce website with Laravel, Vue

A eCommerce using Laravel Version: 1.0 Release of the Laravel eCommerce. Technologies and libraries Laravel 7+, PHP 7+. JavaScript & VueJS Framework.

Jackson Zhang 1 Nov 4, 2021
Laravel FREE E-Commerce Software

Get discount on Digital Ocean Sign-up with Digital Ocean and get $10 discount! Laravel FREE E-Commerce Software Features Provided Products Cart Checko

Jeff Simons Decena 1.7k Jan 4, 2023
GetCandy - A headless E-Commerce API built on top of Laravel.

A headless E-Commerce API built on top of Laravel. Build amazing online stores with full control over functionality and user experience using headless

GetCandy 438 Jan 4, 2023
The truly Laravel E-commerce Framework

Vanilo The Truly Laravel E-commerce Framework Vanilo's aim is that Laravel developers can rapidly create E-commerce applications with pleasure. Curren

Vanilo E-commerce 650 Dec 28, 2022
GetCandy is an open source E-commerce platform which embraces Laravel

GetCandy is an open source E-commerce platform which embraces Laravel as it's foundation and uses it to build a highly extensible, robust and feature rich application you can build any store on.

GetCandy 16 Jun 15, 2022
GetCandy is a package that brings functionality akin to Shopify and other e-commerce platforms to Laravel.

GetCandy is a set of Laravel packages that bring functionality akin to Shopify and other e-commerce platforms to Laravel. You have complete freedom to

GetCandy 7 Oct 27, 2022
Aimeos is THE professional, full-featured and high performance e-commerce package for Laravel

Aimeos Slim package ā­ Star us on GitHub ā€” it helps! Aimeos is THE professional, full-featured and high performance e-commerce package for Laravel! You

Aimeos 101 Sep 14, 2022
Miolica: an e-commerce application that uses React.js as the frontend and Laravel as the backend

Miolica: an e-commerce application that uses React.js as the frontend and Laravel as the backend

Valll 5 Apr 20, 2022
Drag and Drop Website Builder and CMS with E-commerce

Microweber: Drag-and-Drop CMS Current version: 1.2 running on Laravel 8! Download | What is Microweber? | Core features of Microweber | Requirements |

Microweber 2.6k Dec 28, 2022
PrestaShop is a fully scalable open source e-commerce solution.

PrestaShop is an Open Source e-commerce web application, committed to providing the best shopping cart experience for both merchants and customers.

PrestaShop 6.9k Jan 9, 2023
A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.

OpenCart is a free open source ecommerce platform for online merchants. OpenCart provides a professional and reliable foundation from which to build a successful online store.

OpenCart 6.6k Dec 31, 2022
PHP payment library to easily integrate Baltic banklinks (supports old and new iPizza protocol), E-commerce gateaway (Estcard, Nets Estonia), Liisi Payment Link and Pocopay.

PHP Payment library PHP payment library to easily integrate Baltic banklinks, E-commerce gateaway (Estcard, Nets Estonia), Liizi Payment Link and Poco

Rene Korss 34 Apr 27, 2022