This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Helper methods | ||
|
||
Shopper has several helper functions that are ready to use. Here you can find the list of available function that may speed up your development. | ||
|
||
## Thumbnails URL | ||
|
||
After registering your product, Shopper will generate thumbnails for your products. You may want to view the thumbnails displayed in your view or get the thumbnail URL. Product Model uses `Resize` trait to display thumbnails. | ||
|
||
```php | ||
namespace Mckenziearts\Shopper\Plugins\Catalogue\Models; | ||
|
||
use Mckenziearts\Shopper\Traits\Resize; | ||
|
||
class Product extends Model | ||
{ | ||
use Resize; | ||
} | ||
``` | ||
|
||
To set custom thumbnails size you can make it on the shopper config file, for crop image, add sizes on the model name array. | ||
|
||
```php | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Image resize | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Resize and create thumbnails for previewImage on Brand, Category and Product | ||
| Model. | ||
| | ||
*/ | ||
'quality' => 70, | ||
'upsize' => true, | ||
'thumbnails' => [ | ||
[ | ||
'name' => 'medium', | ||
'scale' => '50' | ||
], | ||
[ | ||
'name' => 'small', | ||
'scale' => '25' | ||
], | ||
[ | ||
'name' => 'cropped', | ||
'crop' => [ | ||
'brand' => [ | ||
'145x50' => ['width' => '145', 'height' => '50'] | ||
], | ||
'product' => [ | ||
'1000x1000' => ['width' => '1000', 'height' => '1000'] | ||
], | ||
'category' => [ | ||
'220x197' => ['width' => '220', 'height' => '197'] | ||
] | ||
] | ||
] | ||
], | ||
``` | ||
|
||
#### Display a single image | ||
|
||
```php | ||
@foreach($products as $product) | ||
<img src="{{ $product->getImageUrl() }}" /> | ||
@endforeach | ||
``` | ||
|
||
Or you can specify the preview image relation field name \(attribute\) | ||
|
||
```php | ||
@foreach($products as $product) | ||
<img src="{{ shopperAsset($product->previewImage->disk_name) }}" /> | ||
@endforeach | ||
``` | ||
|
||
Or to display a cropped image | ||
|
||
```php | ||
@foreach($products as $product) | ||
<img src="{{ $product->thumbnail('cropped', '1000x1000') }}" alt="" /> | ||
@endforeach | ||
``` | ||
|
||
#### Display multiple images | ||
|
||
```php | ||
@foreach($product->images as $image) | ||
<img src="{{ shopperAsset($image->disk_name) }}" alt="" /> | ||
@endforeach | ||
``` | ||
|
||
## Website Currency | ||
|
||
If you want to display correct money format, Shopper provide a simple helper to help you, not based on default `money_format` php function : | ||
|
||
```php | ||
shopperMoney($product->offers->last()->price, setting('site_currency')) | ||
``` | ||
|
||
Or inside of any blade template like: | ||
|
||
```text | ||
{{ shopperMoney($product->offers->last()->price, setting('site_currency')) }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Media Manager | ||
|
||
Shopper has a full-fledged Media Manager which allows you to upload files, re-name files, and delete files. You can also add new folders and move files/folders. Basically anything that you would be able to do in any type of Media Manager you can do so in the Shopper Media Manager. | ||
|
||
![](../.gitbook/assets/media_manager.png) | ||
|
||
{% hint style="info" %} | ||
**Notice on File Upload Size** | ||
If you are getting an error when trying to upload large files, this may be a setting that needs to be changed in your PHP. Be sure to check `max_file_upload` and `file_upload_size` | ||
{% endhint %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Settings | ||
|
||
The Settings is the simple «key-value» storage that uses the key to access a value. These storages are usually used to store settings. | ||
The Settings section allows you to set site wide settings you would like. You can add the main headline on your homepage, the shop email address, the default website currency, your site description (important for your seo ranking). | ||
|
||
![](../.gitbook/assets/settings.png) | ||
|
||
So, if you updated a setting inside of the settings tab and it had the key of site_title you would then be able to reference that setting any where on your site by doing the following: | ||
|
||
```php | ||
<?php | ||
//Using the helper | ||
echo setting('site_title'); | ||
``` | ||
Or inside of any blade template like: | ||
|
||
```text | ||
{{ setting('site_title') }} | ||
``` | ||
|
||
So, now you can update all settings in Shopper Global settings tab and reference them in your application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters