Giter Club home page Giter Club logo

laravel-shopr's People

Contributors

cotsog avatar mattias-persson avatar svenluijten 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

laravel-shopr's Issues

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

Class 'NumberFormatter' not found

Describe the bug
The class NumberFormatter isn't found, probable cause is missing php-intl extension.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure php-intl isn't installed or enabled in the CLI environment.
  2. Run phpunit.
  3. See error.

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,

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?

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

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?

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

  • Database table and model
  • REST endpoint for applying a code
  • Validation, is the code valid?
  • Flexibility so that everyone can add their own validation logics
  • Inclusion in the order and confirmation emails
  • A good abstraction for applying discounts to each new payment provider
  • Access applied discount coupons on the cart summary
  • Translatable validation errors
  • Tests

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

If a transaction fails, the cart should not be cleared and no order should be created

Describe the bug
In the checkout process, if the transaction fails (for example due to insufficient funds), the cart will still be cleared and the order will be created with the payment_status 'pending'. No order should be created and the cart should still be there, in order to reattempt the checkout.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure you have too little money left on your card. This can only be reproduced with the live environment.
  2. Run the checkout process. The cart will be cleared and order created even though the checkout fails.

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

  • Getting the cart summary
  • Getting the current cart count
  • Clearing the cart
  • Adding a cart item
  • Updating the quantity of a cart item
  • Removing a cart item
  • Applying a discount 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 ๐Ÿค”

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.