Skip to content

Commit

Permalink
Merge pull request #357 from mayank-webkul/doc-update-2.x
Browse files Browse the repository at this point in the history
Doc update 2.x
  • Loading branch information
devansh-webkul authored Nov 2, 2023
2 parents cfcf7e0 + 5f8ba06 commit f443b79
Show file tree
Hide file tree
Showing 67 changed files with 5,456 additions and 16,150 deletions.
3 changes: 2 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports = {
],
sidebar: {
'/1.x/': require('./version-configs/1.x'),
'/1.5.x/': require('./version-configs/1.5.x')
'/1.5.x/': require('./version-configs/1.5.x'),
'/2.x/': require('./version-configs/2.x')
}
},
markdown: {
Expand Down
5 changes: 3 additions & 2 deletions docs/.vuepress/theme/components/NavLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
<OutboundLink />
</a>

<div class="nav-item" v-if="this.$route.path.split('/')[1] != ''">
<div class="nav-item" v-if="$route.path.split('/')[1] !== ''">
<select v-model="version" @change="changeVersion">
<option value="1.x">1.x</option>
<option value="1.5.x">1.5.x</option>
<option value="2.x">2.x</option>
</select>
</div>
</nav>
Expand All @@ -55,7 +56,7 @@ export default {
data() {
return {
version: '1.5.x',
version: '2.x',
};
},
Expand Down
1 change: 0 additions & 1 deletion docs/.vuepress/theme/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default {
@require '../styles/wrapper.styl'
.page
text-align justify
padding-bottom 2rem
display block
Expand Down
101 changes: 101 additions & 0 deletions docs/.vuepress/version-configs/2.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* set version */
let version = '2.x';

/* version prefix setter */
function setVersionPrefix(children) {
if (children.constructor === Array) {
return children.map(child => {
child[0] = `/${version}/${child[0]}`;
return child;
});
}
return `/${version}/${children}`;
}

/* module export */
module.exports = [
{
title: 'Prologue',
path: setVersionPrefix('prologue'),
collapsable: true,
children: setVersionPrefix([
['prologue/upgrade-guide', 'Upgrade Guide'],
['prologue/contribution-guide', ' Contribution Guide']
])
},
{
title: 'Introduction',
path: setVersionPrefix('introduction'),
collapsable: true,
children: setVersionPrefix([
['introduction/requirements', 'Requirements'],
['introduction/installation', 'Installation'],
['introduction/docker', 'Docker']
])
},
{
title: 'Architecture concepts',
path: setVersionPrefix('architecture'),
collapsable: true,
children: setVersionPrefix([
['architecture/packages', 'Packages'],
['architecture/frontend', 'Frontend'],
['architecture/theme', 'Theme'],
['architecture/performance', 'Performance'],
['architecture/repository-pattern', 'Repository Pattern'],
['architecture/modular-design', 'Modular Design']
])
},
{
title: 'Package Development',
path: setVersionPrefix('packages'),
collapsable: true,
children: setVersionPrefix([
['packages/create-package', 'Getting Started'],
['packages/create-migrations', 'Migrations'],
['packages/create-models', 'Models'],
['packages/store-data-through-repositories', 'Repository'],
['packages/routes', 'Routes'],
['packages/controllers', 'Controllers'],
['packages/views', 'Views'],
['packages/localization', 'Localization'],
['packages/blade-components', 'Blade Components'],
['packages/layouts', 'Layouts'],
['packages/assets', 'Assets'],
['packages/add-menu-in-admin', 'Admin Menu'],
['packages/customize-hompepage-menu.md', 'Homepage Menu'],
['packages/validation', 'Validation'],
['packages/datagrid', 'DataGrid'],
['packages/create-acl', 'Access Control List'],
['packages/create-custom-configuration', 'Custom Configuration']
])
},
{
title: 'Digging Deeper',
path: setVersionPrefix('advanced'),
collapsable: true,
children: setVersionPrefix([
['advanced/create-shipping-method', 'Shipping Method'],
['advanced/create-payment-method', 'Payment Method'],
['advanced/create-product-type', 'Product Type'],
['advanced/events', 'Events Listeners'],
['advanced/helpers', 'Helpers'],
['advanced/override-core-model', 'Override Core Models'],
['advanced/render-event', 'View Render Event'],
['advanced/change-email-template.md', 'Email Template'],
['advanced/indexing-products-to-elasticsearch.md', 'Configure Elasticsearch'],
['advanced/security-practice', 'Best Security Practices'],
])
},
{
title: 'Themes',
path: setVersionPrefix('themes'),
collapsable: true,
children: setVersionPrefix([
['themes/create-theme', 'Store Theme'],
['themes/create-admin-theme', 'Admin Theme'],
['themes/notification', 'Real Time Notification'],
['themes/integrate-image-search-in-theme', 'Image Search']
])
}
]
33 changes: 33 additions & 0 deletions docs/2.x/advanced/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Digging Deeper

Welcome to the "Digging Deeper" section of the Bagisto documentation. Here, we will explore various advanced topics related to Bagisto, which will enable you to customize and extend your e-commerce platform to suit your specific needs.

We expect you to have knowledge of creating packages in Laravel. If you are new to package development, we recommend referring to the [Package Development](../packages/create-package.html) section for a primer on creating and managing packages in Laravel.

### Creating Payment Methods

Bagisto provides a flexible and configurable system for integrating different payment methods into your e-commerce store. We will guide you through the process of setting up and configuring payment methods, allowing you to offer a variety of options to your customers while ensuring a seamless and secure checkout experience.

### Product Types

Bagisto supports different types of products, allowing you to showcase and sell a wide range of items. We will delve into the details of configuring and managing product types, giving you the ability to define specific attributes and behaviors for each product category.

### Shipping Methods

Efficient and reliable shipping is crucial for any e-commerce business. Bagisto offers robust features for managing shipping methods, enabling you to define various shipping options, rates, and rules based on factors such as location, weight, or order value. We will explain how to configure and customize shipping methods to streamline your order fulfillment process.

### Events and Event Handlers

Events and event handlers provide a powerful way to extend the functionality of Bagisto by allowing you to react to specific actions or triggers within the application. We will show you how to utilize events and event handlers effectively, enabling you to integrate custom functionalities and automate processes.

### Helpers

Bagisto includes a comprehensive set of helper functions that simplify common development tasks and enhance productivity. We will explore the various helper functions available, explaining their purpose and usage to assist you in writing clean and efficient code.

### Indexing through Elastic

To optimize search performance, Bagisto integrates with Elasticsearch, a highly scalable search engine. We will guide you through the process of indexing your data using Elastic, improving the search functionality of your e-commerce store and providing a seamless search experience for your customers.

### Overriding Core Models

Sometimes, you may need to modify or extend the default behavior of Bagisto's core models to accommodate your specific business requirements. We will demonstrate how to override core models effectively, enabling you to customize the behavior of Bagisto without modifying the underlying codebase.
106 changes: 106 additions & 0 deletions docs/2.x/advanced/change-email-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Email Template

[[TOC]]

## Introduction

In this section, we will explain how to customize the email templates in Bagisto. Customizing email templates allows you to personalize the appearance of your emails according to your preferences.

## Email Template Flow

Before we dive into template customization, let's understand how email templates work in Bagisto.

Bagisto provides various mail notification classes, such as **`CancelOrderAdminNotification`** and **`NewCustomerNotification`**, located in the **`Webkul\Admin\Mail`** namespace. Let's take the **`CancelOrderAdminNotification`** class as an example.

```php
<?php

namespace Webkul\Admin\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class CancelOrderAdminNotification extends Mailable
{
use Queueable, SerializesModels;

/**
* Order.
*
* @var \Webkul\Sales\Contracts\Order
*/
public $order;

/**
* Constructor.
*
* @param \Webkul\Sales\Contracts\Order $order
* @return void
*/
public function __construct($order)
{
$this->order = $order;
}

/**
* Build.
*
* @return void
*/
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel-admin');
}
}
```

In the **`build()`** method of the above class, you can see that the main view file, **`view('shop::emails.sales.order-cancel-admin')`**, is loaded from the shop package.

Now, let's explore the view file mentioned in **`view('shop::emails.sales.order-cancel-admin')`**. If you check the file at the path **`packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel-admin.blade.php`**, you will find it. This view file uses the main layout component **`shop::emails.layouts.master`**.

```php
@component('shop::emails.layouts.master')
...
@endcomponent
```

This layout component is responsible for the overall email layout. If desired, you can explore this file as well. Now, let's proceed to learn how to change these email templates.

## Changing Email Template

To customize the email template, the recommended approach is to override the package's view. Since all email views are defined in the shop package, we need to override the view within the shop package.

Here's how you can override the view for the same file we mentioned above, **`view('shop::emails.sales.order-cancel-admin')`**.

Bagisto registers two locations for views: the application's **`resources/themes`** directory specified in **`config/themes.php`**, and the directory you specify. If you are using the default theme, **`shop`** package, Bagisto will first check if a custom version of the view exists in the **`resources/themes/default`** directory. If the view has not been customized, Bagisto will then search the package's view directory.

To override the view, create the same directory structure in the application's **`resources/themes/default`** directory:

```
- resources/
└── themes/
└── default/
└── views/
└── emails/
└── sales/
└── order-cancel-admin.blade.php
```

For example, create a file named **`order-cancel-admin.blade.php`** within the **`sales`** directory, and modify its content as desired:

```blade
Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum porro cumque numquam neque dicta quo, accusantium, perferendis sed beatae nesc
iunt eum impedit vel doloribus dolor excepturi vero tenetur perspiciatis saepe?
```

Now you can test the modified email template.

## Email Template Sample

![Email Template Sample](../../assets/1.5.x/images/advanced-topics/mail-sample.png)
Loading

0 comments on commit f443b79

Please sign in to comment.