PHP code example of roundly-consulting / shops-for-laravel

1. Go to this page and download the library: Download roundly-consulting/shops-for-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

roundly-consulting / shops-for-laravel example snippets


use RoundlyConsulting\Money\Money;
use RoundlyConsulting\Shops\Facades\Shops;
use RoundlyConsulting\Shops\Products\Product;

$product = Product::create(['name' => 'Sparkling Water']);

$variant = $product->defaultVariant;
$variant->update(['price' => Money::ofMinor(199, 'EUR')]);

Shops::inventory($variant)->receive(50, note: 'Opening stock');

use RoundlyConsulting\Shops\Cart\Cart;
use RoundlyConsulting\Shops\Orders\DataTransferObjects\Address;
use RoundlyConsulting\Shops\Orders\DataTransferObjects\PlaceOrderData;

$cart = Cart::create(['currency' => 'EUR']);
Shops::cart($cart)->add($variant, 2);
Shops::cart($cart)->price()->getFinalPrice();   // 3.98 EUR, tax ateway → Paid
Shops::order($order)->fulfil();                 // the reservation becomes a sale
bash
composer vendor:publish --tag="shops-migrations"
php artisan vendor:publish --tag="media-migrations" --tag="reviews-migrations" --tag="attributes-migrations" \
    --tag="coupons-migrations" --tag="credits-migrations" --tag="addresses-migrations"
php artisan migrate