Skip to content

vvkgpt48/merchium-advanced-app

 
 

Repository files navigation

Merchium Advanced App

Example app for Merchium that demonstrates the use of external JavaScript, external HTML/Smarty content, webhooks, and payment service integration.

The app implements the following features:

1. Snowfall for the storefront
1. Welcome popup
1. The "Add to cart" counter
1. Example payment

The app is based on the Yii 2 Basic Application Template.

Requirements

PHP 5.4.0 and a web server supporting it.

In the example below we'll use PHP's built-in server, SQLite, and ngrok. You can use MySQL or any other database.

Check the requirements with php requirements.php.

Install

  1. Clone repo and switch to the app directory:

    $ git clone https://github.com/merchium/merchium-advanced-app.git
    $ cd merchium-advanced-app
  2. Install Composer.

  3. Install the plugin and dependencies by running the following command:

    $ composer global require "fxp/composer-asset-plugin:1.0.0"
    
    $ composer update

Configure DB

  1. Create a DB from the provided example:

    $ cp sqlite.db merchium-advanced-app.db
  2. Create a DB config from the provided example:

    $ cp config/db.php.example config/db.php
  3. Edit the DB config (note that the DB path must be absolute):

    <?php
    
    return [
    	'class' => 'yii\db\Connection',
    	'dsn' => 'sqlite:/absolute/path/to/merchium-advanced-app.db',
    	'charset' => 'utf8',
    ];

Note: The DB template sqlite.db already has some data. If you're starting from scratch or using a different database (e.g. MySQL), apply the migrations:

$ php yii migrate

Launch

  1. Run PHP's built-in dev server:

    php -S localhost:8000
  2. Use ngrok to get an https URL pointing to your server:

    $ ngrok http 8000
    ...
    Forwarding                    https://3cd89e8a.ngrok.com -> 127.0.0.1:8000
    ...

Create a Merchium Marketplace App

  1. Go to https://3cd89e8a.ngrok.com/web/index.php?r=site%2Flogin and login to the dashboard with username admin and password admin.

You'll see the app's admin panel and install page URLs.

  1. Open your Merchium partner page on a new tab and create an app. Use the admin panel and install page URLs from the dashboard.

  2. Switch to App permissions and check the following permissions:

    • View, create, edit, and delete custom script connections (ScriptTags)
    • View, create, edit, and delete custom HTML and Smarty 3 content connections to hooks (TemplateHooks)
    • View, create, edit, and delete payment processors (PaymentProcessors)
    • Create, edit, and delete webhooks (Webhooks)
  3. Create a config from the provided example:

    $ cp config/params.php.example config/params.php
  4. Open config/params.php and paste the App key and Client secret values from the Merchium partner page into the respective params:

    <?php
    
    return [
    
    	'adminEmail' => 'admin@example.com',
    	'applicationName' => 'Merchium Example App',
    	'companyName' => 'My Company',
    
    	'userPasswordResetTokenExpire' => 3600,
    
    	/**
    	 * Application params. Required for installation.
    	 */
    	'appKey' => 'APPKEY12345',
    	'clientSecret' => 'CLIENTSECRET12345',
    
    ];
  5. Restart the server to apply the new params.

Install the App in a Dev Store

  1. Create a dev store in your Merchium partner panel.

  2. Go to the app page and install it to the dev store.

Directories

assets/             assets definition
behaviors/          behaviors definition
commands/           console commands (controllers)
config/             application configurations
controllers/        Web controller classes
mail/               view files for e-mails
models/             model classes
runtime/            files generated during runtime
tests/              various tests for the basic application
vendor/             dependent 3rd-party packages
views/              view files for the Web application
web/                the entry script and Web resources
widgets/            widgets for view files for the Web application

About

Merchium Advanced App

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 84.8%
  • JavaScript 14.1%
  • CSS 1.1%