Giter VIP home page Giter VIP logo

yii2-ecommerce-website's Introduction

Yii2 E-commerce application


Yii2 E-commerce system

Features

  • Bootstrap 4
  • Custom Admin template in backend
  • Product Management
  • Implement cart page
  • Checkout for guests
  • Checkout for authorized users
  • Sending email when order is made
  • Payments with PayPal - PayPal buttons
  • Order validation
  • Display order in backend
  • Dashboard with basic statistics
    • Total earnings
    • Total products sold
    • Total number of orders made
    • Total users
    • Earnings by day
    • Revenue by country

Demo

I am working on demo. It will be available soon.

Installation

  1. Clone the repository
  2. Go to the project root directory and run composer install
  3. Run php init from the project root directory and choose your desired environment
  4. Create the database
  5. Open common/config/main-local.php
    • Configure database credentials by changing the following lines
      'dsn' => 'mysql:host=localhost;dbname=your_website_db',
      'username' => 'root',
      'password' => '',
      'charset' => 'utf8mb4',
    • If you want to use real SMTP credentials to send emails, configure the mail provider by replacing mailer component with the following code
      'mailer' => [
          'class' => 'yii\swiftmailer\Mailer',
          'transport' => [
              'class' => 'Swift_SmtpTransport',
              'host' => 'SMTP_HOST',
              'username' => 'SMTP_USERNAME',
              'password' => 'SMTP_PASSWORD',
              'port' => 'SMTP_PORT',
              'encryption' => 'tls',
          ],
      ],
  6. Run php yii migrate to apply all system migrations.
  7. Create virtual hosts for frontend/web and backend/web directories. Virtual Host templates
    <VirtualHost *:80>
        ServerName yii2-ecommerce.localhost
        DocumentRoot "/path/to/ecommerce-website/frontend/web/"
        
        <Directory "/path/to/ecommerce-website/frontend/web/">
            # use mod_rewrite for pretty URL support
            RewriteEngine on
            # If a directory or a file exists, use the request directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            # Otherwise forward the request to index.php
            RewriteRule . index.php
    
            # use index.php as index file
            DirectoryIndex index.php
    
            # ...other settings...
            # Apache 2.4
            Require all granted
            
            ## Apache 2.2
            # Order allow,deny
            # Allow from all
        </Directory>
    </VirtualHost>
    
    
    <VirtualHost *:80>
        ServerName backend.yii2-ecommerce.localhost
        DocumentRoot "/path/to/ecommerce-website/backend/web/"
        
        <Directory "/path/to/ecommerce-website/backend/web/">
            # use mod_rewrite for pretty URL support
            RewriteEngine on
            # If a directory or a file exists, use the request directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            # Otherwise forward the request to index.php
            RewriteRule . index.php
    
            # use index.php as index file
            DirectoryIndex index.php
    
            # ...other settings...
            # Apache 2.4
            Require all granted
            
            ## Apache 2.2
            # Order allow,deny
            # Allow from all
        </Directory>
    </VirtualHost>
    
  8. Open common/config/params-local.php and replace the content with the following code Make sure you create PayPal application and take ClientId and Secret.
    <?php
    return [
        'frontendUrl' => 'YOUR_FRONTEND_HOST', // Ex: http://yii2-ecommerce.localhost
        'paypalClientId' => '',
        'paypalSecret' => '',
        'vendorEmail' => '[email protected]'
    ];

Building assets

The project uses webpack to build the assets.
The project styles and bootstrap styles are built together. Source files are located in frontend/scss and backend/js.

Bootstrap customization

If you want to customize bootstrap variables, open frontend/scss/bootstrap-variables.scss and override any bootstrap variable.
Check the following link for more information about bootstrap customization

For Development

Runnpm run dev to build the files and start watching them. This will generate unminified versions of the files and will generate source maps as well

For production

Run npm run prod to build the files for production. This will generate minified files.

Create admin user

Run the following console command to create admin user. PASSWORD is optional, you can skip it and system will generate a random password

php yii app/create-admin-user USERNAME [PASSWORD]

yii2-ecommerce-website's People

Contributors

thecodeholic 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

yii2-ecommerce-website's Issues

console/AppController/actionCreateAdminUser

Theres no $user->auth_key definition in console/AppController/actionCreateAdminUser, so it says, when we try '$ php yii app/create-admin-user USERNAME [PASSWORD]':

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000]: General error: 1364 Field 'auth_key' doesn't have a default value.

"Undefined index: frontendUrl" error when adding a new product

I get this error when I add a new product (with or without the image):

Undefined index: frontendUrl

1. in C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\common\models\Product.php at line 174


        return self::formatImageUrl($this->image);
    }
 
    public static function formatImageUrl($imagePath)
    {
        if ($imagePath) {
            **return Yii::$app->params['frontendUrl'] . '/storage' . $imagePath;**
        }
 
        **return Yii::$app->params['frontendUrl'] . '/img/no_image_available.png';**  
    }
 
    /**
     * Get short version of the description
     *
     * @return string
     * @author Zura Sekhniashvili <[email protected]>
     */
    public function getShortDescription()

yii\base\ErrorException: Undefined index: frontendUrl in C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\common\models\Product.php:174
Stack trace:
#0 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\common\models\Product.php(174): yii\base\ErrorHandler->handleError()
#1 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\common\models\Product.php(165): common\models\Product::formatImageUrl()
#2 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\backend\views\product\view.php(36): common\models\Product->getImageUrl()
#3 [internal function]: yii\base\View->{closure}()
#4 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\widgets\DetailView.php(245): call_user_func()
#5 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\widgets\DetailView.php(143): yii\widgets\DetailView->normalizeAttributes()
#6 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\BaseObject.php(109): yii\widgets\DetailView->init()
#7 [internal function]: yii\base\BaseObject->__construct()
#8 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\di\Container.php(418): ReflectionClass->newInstanceArgs()
#9 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\di\Container.php(169): yii\di\Container->build()
#10 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\BaseYii.php(365): yii\di\Container->get()
#11 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\Widget.php(138): yii\BaseYii::createObject()
#12 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\backend\views\product\view.php(56): yii\base\Widget::widget()
#13 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\View.php(348): require('C:\Users\Max\De...')
#14 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\View.php(257): yii\base\View->renderPhpFile()
#15 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\View.php(156): yii\base\View->renderFile()
#16 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\Controller.php(409): yii\base\View->render()
#17 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\backend\controllers\ProductController.php(68): yii\base\Controller->render()
#18 [internal function]: backend\controllers\ProductController->actionView()
#19 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array()
#20 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\Controller.php(180): yii\base\InlineAction->runWithParams()
#21 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction()
#22 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\web\Application.php(104): yii\base\Module->runAction()
#23 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\vendor\yiisoft\yii2\base\Application.php(392): yii\web\Application->handleRequest()
#24 C:\Users\Max\Desktop\Archivio\Websites\WAMP\frameworks\yii2\webroot\backend\web\index.php(17): yii\base\Application->run()
#25 {main}

theming frontend

Is it possible to customize the frontend layout with a theme ?
Thanks

SQL database?

Does this use an sql database? if yes, may you help me locate the file?

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.