The Bagisto Wishlist Share package is an enhanced wishlist sharing functionality for Bagisto e-commerce platform that allows customers to create shareable links for their wishlists with social media integration, QR code generation, and comprehensive admin management.
packages/Webkul/WishlistShare/
├── src/
│ ├── Config/ # Configuration files
│ ├── Contracts/ # Interface contracts
│ ├── Database/ # Migrations and seeders
│ ├── Events/ # Event classes
│ ├── Http/ # Controllers and requests
│ ├── Listeners/ # Event listeners
│ ├── Models/ # Eloquent models
│ ├── Providers/ # Service providers
│ ├── Repositories/ # Repository pattern
│ ├── Resources/
│ │ ├── assets/
│ │ │ ├── css/ # Package stylesheets
│ │ │ └── js/ # JavaScript files
│ │ │ └── wishlist-share-inject.js # Universal injection script
│ │ ├── lang/ # Language files
│ │ └── views/ # Blade templates
│ │ ├── admin/ # Admin panel views
│ │ ├── customer/ # Customer-facing views
│ │ └── components/ # Reusable components
│ └── Routes/ # Route definitions
├── composer.json # Package dependencies
├── package.json # Frontend dependencies
└── README.md # This documentation
wishlist-share-inject.js: Universal theme compatibility script (published topublic/)WishlistShareServiceProvider.php: Main service provider with auto-integrationWishlistShare.php: Main model with sharing logicWishlistShareController.php: API and web controllersshare-modal.blade.php: Modal component for sharing interfacewishlist-share-integration.blade.php: Integration component for themes
- Shareable Wishlist Links: Generate unique, secure links for wishlist sharing
- Social Media Integration: Share wishlists on Facebook, Twitter, LinkedIn, and via email
- QR Code Generation: Automatic QR code creation for easy mobile sharing
- Expiration Management: Configurable expiration dates for shared wishlists
- Privacy Controls: Public/private wishlist sharing options
- View Tracking: Track how many times a shared wishlist has been viewed
- Analytics Dashboard: Comprehensive analytics with date range filtering
- Share Management: View, manage, and delete customer wishlist shares
- Bulk Operations: Mass delete expired or selected shares
- Export Functionality: Export share data to CSV
- Settings Configuration: Customize button colors, labels, and social sharing options
- Platform Statistics: Track sharing across different social platforms
- Modal Interface: Clean, user-friendly sharing modal
- Responsive Design: Mobile-optimized sharing interface
- Copy to Clipboard: One-click link copying functionality
- QR Code Display: In-modal QR code generation and download
- Social Sharing Buttons: Direct sharing to social platforms
- PHP ^8.2
- Laravel ^11.0
- Bagisto e-commerce platform (v2.0+)
- endroid/qr-code ^5.0
- Node.js & NPM (for asset compilation)
composer require theihasan/bagisto-wishlist-shareIf auto-discovery is disabled, manually add to config/app.php:
'providers' => [
// ...
Ihasan\BagistoWishlistShare\Providers\WishlistShareServiceProvider::class,
],# Publish all package resources
php artisan vendor:publish --provider="Ihasan\BagistoWishlistShare\Providers\WishlistShareServiceProvider"
# Or publish individually:
php artisan vendor:publish --tag=wishlist-share-config
php artisan vendor:publish --tag=wishlist-share-assets
php artisan vendor:publish --tag=wishlist-share-views
php artisan vendor:publish --tag=wishlist-share-lang
php artisan vendor:publish --tag=wishlist-share-injectphp artisan migrate# If using Vite (Bagisto 2.0+)
npm run build
# Or if using Laravel Mix
npm run productionphp artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan route:clearphp artisan db:seed --class="Ihasan\BagistoWishlistShare\Database\Seeders\WishlistShareSeeder"Follow the installation steps above. The package will automatically integrate with your existing Bagisto installation.
If you want to customize or integrate manually:
- Copy Package Files
# Copy the package to your packages directory
cp -r vendor/theihasan/bagisto-wishlist-share packages/Webkul/WishlistShare- Update Composer.json
{
"autoload": {
"psr-4": {
"Ihasan\\BagistoWishlistShare\\": "packages/Webkul/WishlistShare/src/"
}
}
}- Register in packages.php
Add to
config/concord.php:
'modules' => [
// ... existing modules
Ihasan\BagistoWishlistShare\Providers\ModuleServiceProvider::class,
]For package development:
- Clone Repository
git clone https://github.com/theihasan/bagisto-wishlist-share.git packages/Webkul/WishlistShare- Install Dependencies
cd packages/Webkul/WishlistShare
composer install
npm install- Build Assets
npm run buildAdd to your .env file:
# Wishlist Share Configuration
WISHLIST_SHARE_ENABLED=true
WISHLIST_SHARE_TOKEN_LENGTH=32
WISHLIST_SHARE_EXPIRES_DAYS=30
WISHLIST_SHARE_QR_SIZE=200- Login to Bagisto Admin Panel
- Navigate to Configuration → Wishlist Share
- Configure social sharing settings
- Set button colors and labels
- Enable/disable features as needed
The package automatically integrates with the default Bagisto theme. For custom themes:
Add to your wishlist template:
@if(config('wishlist-share.enabled'))
@wishlistShare
@wishlistShareAssets
@endifOr manually include:
@include('wishlist-share::customer.share-modal')Override default styles by publishing views and modifying:
php artisan vendor:publish --tag=wishlist-share-viewsEdit: resources/views/vendor/wishlist-share/customer/share-modal.blade.php
The package configuration is located at config/wishlist-share.php:
return [
'enabled' => true,
'social_platforms' => [
'facebook' => [
'enabled' => true,
'url' => 'https://www.facebook.com/sharer/sharer.php?u=',
],
'twitter' => [
'enabled' => true,
'url' => 'https://twitter.com/intent/tweet?url=',
],
'linkedin' => [
'enabled' => true,
'url' => 'https://www.linkedin.com/sharing/share-offsite/?url=',
],
'email' => [
'enabled' => true,
'subject' => 'Check out my wishlist',
],
],
'qr_code' => [
'enabled' => true,
'size' => 200,
'margin' => 10,
],
'share_token' => [
'length' => 32,
'expires_in_days' => 30,
],
];Access admin settings via: Admin Panel → Wishlist Share → Settings
Configure:
- Button colors and labels
- Social sharing button colors
- Add to wishlist button customization
- View product button customization
- id (Primary Key)
- customer_id (Foreign Key to customers table)
- share_token (Unique 64-character string)
- title (Nullable string)
- description (Nullable text)
- is_public (Boolean, default: true)
- expires_at (Nullable timestamp)
- view_count (Integer, default: 0)
- shared_platforms (JSON, nullable)
- created_at, updated_at (Timestamps)- id (Primary Key)
- wishlist_share_id (Foreign Key to wishlist_shares table)
- product_id (Foreign Key to products table)
- product_options (JSON, nullable)
- quantity (Integer, default: 1)
- created_at, updated_at (Timestamps)POST /api/wishlist-share/create- Create a new wishlist shareGET /api/wishlist-share/my-shares- Get user's wishlist shares
GET /api/wishlist-share/{token}- View shared wishlist data
POST /customer/account/wishlist/share/create- Create wishlist shareGET /customer/account/wishlist/share/{token}/qr- Generate QR codeDELETE /customer/account/wishlist/share/{token}- Delete wishlist shareGET /shared-wishlist/{token}- View shared wishlist page
The package provides multiple integration methods to work with different Bagisto themes and customization needs:
The package automatically integrates with the default Bagisto wishlist page by:
- Adding a "Share Wishlist" button next to the "Delete All" button
- Including the share modal and injection script
- Using the
wishlist-share-inject.jsfor universal theme compatibility
<!-- In your custom wishlist template -->
@include('wishlist-share::components.wishlist-share-integration', [
'buttonPosition' => 'inline', // 'inline' or 'floating'
'showInlineButton' => true, // Show additional inline button
'floatingPosition' => [ // Custom floating position
'top' => '150px',
'right' => '20px'
]
])<!-- In your custom wishlist template -->
<div class="wishlist-actions">
@if(auth('customer')->check() && config('wishlist-share.enabled'))
<button onclick="document.getElementById('wishlist-share-modal').style.display = 'flex'" class="btn btn-primary">
<i class="fas fa-share-alt"></i> Share Wishlist
</button>
@endif
</div>
<!-- Include the share modal -->
@include('wishlist-share::customer.share-modal')
<script src="{{ asset('wishlist-share-inject.js') }}" defer></script><!-- In your custom wishlist template -->
<div class="wishlist-actions">
@if(auth('customer')->check() && config('wishlist-share.enabled'))
<button onclick="openWishlistShareModal()" class="btn btn-primary">
<i class="fas fa-share-alt"></i> Share Wishlist
</button>
@endif
</div>
<!-- Include the share modal -->
@wishlistShare
@wishlistShareAssets// Custom share button handler
function openWishlistShareModal() {
document.getElementById('wishlist-share-modal').style.display = 'flex';
}
// Listen for share events
document.addEventListener('wishlist-shared', function(event) {
console.log('Wishlist shared:', event.detail);
// Custom tracking or analytics
});/* Override default styles */
.wishlist-share-modal {
/* Custom modal styles */
}
.wishlist-share-btn {
background-color: var(--primary-color);
/* Custom button styles */
}<?php
namespace App\Http\Controllers;
use Ihasan\BagistoWishlistShare\Repositories\WishlistShareRepository;
class CustomWishlistController extends Controller
{
public function __construct(
protected WishlistShareRepository $wishlistShareRepository
) {}
public function myCustomShares()
{
$customer = auth('customer')->user();
$shares = $this->wishlistShareRepository
->where('customer_id', $customer->id)
->with(['items.product'])
->get();
return view('custom.my-shares', compact('shares'));
}
}<?php
namespace App\Listeners;
use Ihasan\BagistoWishlistShare\Events\WishlistShared;
class CustomWishlistShareListener
{
public function handle(WishlistShared $event)
{
$wishlistShare = $event->wishlistShare;
// Custom logic: send notification, track analytics, etc.
$this->sendNotificationToAdmin($wishlistShare);
$this->trackCustomAnalytics($wishlistShare);
}
}Register in EventServiceProvider:
protected $listen = [
WishlistShared::class => [
CustomWishlistShareListener::class,
],
];<?php
namespace App\Repositories;
use Ihasan\BagistoWishlistShare\Repositories\WishlistShareRepository;
class CustomWishlistShareRepository extends WishlistShareRepository
{
public function getPopularShares($limit = 10)
{
return $this->model
->orderBy('view_count', 'desc')
->limit($limit)
->get();
}
public function getSharesByDateRange($startDate, $endDate)
{
return $this->model
->whereBetween('created_at', [$startDate, $endDate])
->with(['customer', 'items'])
->get();
}
}<?php
// routes/api.php
Route::middleware('auth:sanctum')->group(function () {
Route::get('my-wishlist-shares', [CustomApiController::class, 'myShares']);
Route::post('share-wishlist', [CustomApiController::class, 'createShare']);
});
// Controller
class CustomApiController extends Controller
{
public function myShares(Request $request)
{
$shares = app(WishlistShareRepository::class)
->where('customer_id', auth()->id())
->paginate($request->get('per_page', 15));
return response()->json([
'data' => $shares,
'message' => 'Shares retrieved successfully'
]);
}
}// React Native / Mobile App
const shareWishlist = async (wishlistData) => {
try {
const response = await fetch('/api/wishlist-share/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(wishlistData)
});
const result = await response.json();
if (result.success) {
// Handle successful share
shareToSocialMedia(result.data.share_url);
}
} catch (error) {
console.error('Share failed:', error);
}
};<?php
namespace Tests\Feature;
use Tests\TestCase;
use Webkul\Customer\Models\Customer;
use Ihasan\BagistoWishlistShare\Models\WishlistShare;
class WishlistShareTest extends TestCase
{
public function test_customer_can_create_wishlist_share()
{
$customer = Customer::factory()->create();
$response = $this->actingAs($customer, 'customer')
->post('/customer/account/wishlist/share/create', [
'title' => 'My Test Wishlist',
'description' => 'Test description',
'is_public' => true,
'expires_in_days' => 30
]);
$response->assertStatus(200)
->assertJson(['success' => true]);
$this->assertDatabaseHas('wishlist_shares', [
'customer_id' => $customer->id,
'title' => 'My Test Wishlist'
]);
}
}-
Creating a Share:
- Navigate to your wishlist
- Click the "Share Wishlist" button
- Fill in title and description (optional)
- Set expiration date
- Choose privacy settings
- Click "Create Share Link"
-
Sharing Options:
- Copy link to clipboard
- Share on social media (Facebook, Twitter, LinkedIn)
- Send via email
- Download/display QR code
-
Analytics Dashboard:
- View total shares, views, and conversion metrics
- Filter by date ranges (7, 30, 90 days, 1 year)
- Monitor top-performing shares
- Track platform-wise sharing statistics
-
Share Management:
- View all customer shares
- Filter and search shares
- Delete individual or bulk shares
- Clean up expired shares
- Export share data
The package provides custom Blade directives:
@wishlistShare
<!-- Renders the share modal -->
@wishlistShareAssets
<!-- Includes package CSS and JS assets -->Published views can be customized at:
resources/views/vendor/wishlist-share/customer/share-modal.blade.phpresources/views/vendor/wishlist-share/customer/shared-wishlist.blade.phpresources/views/vendor/wishlist-share/admin/
Language files are published to:
resources/lang/vendor/wishlist-share/en/app.phpresources/lang/vendor/wishlist-share/en/admin.php
Fired when a wishlist is shared:
use Ihasan\BagistoWishlistShare\Events\WishlistShared;
// Event data includes:
// - $wishlistShare (WishlistShare model instance)LogWishlistShare- Logs wishlist sharing activity
Location: src/Models/WishlistShare.php
Key Methods:
isExpired()- Check if share has expiredisAccessible()- Check if share is public and not expiredincrementViewCount()- Increment view counter
Relationships:
customer()- Belongs to Customeritems()- Has many WishlistShareItem
Location: src/Models/WishlistShareItem.php
Relationships:
wishlistShare()- Belongs to WishlistShareproduct()- Belongs to Product
Location: src/Repositories/WishlistShareRepository.php
Key Methods:
findByToken($token)- Find share by tokengetFilteredShares($filters)- Get filtered shares for admingetAnalyticsData($filters)- Get analytics datacleanExpiredShares()- Remove expired shares
The package includes a universal injection script that provides theme-agnostic integration:
- Auto-Detection: Automatically detects wishlist pages
- Smart Placement: Tries multiple strategies to place the share button optimally
- Fallback Support: Uses floating button if inline placement fails
- Theme Compatibility: Works with Velocity, custom themes, and future Bagisto versions
- Responsive Design: Adapts to mobile and desktop layouts
- Error Handling: Graceful degradation with retry mechanisms
- Inline Placement: Attempts to place button near existing UI elements
- Floating Placement: Falls back to a floating button with animations
- Text-based Detection: Finds elements by text content ("Delete All", "Wishlist")
- CSS Selector Matching: Uses common Bagisto theme selectors
// The script can be configured via window.WishlistShareConfig
window.WishlistShareConfig = {
enabled: true,
debug: false,
buttonPosition: 'floating', // 'inline' or 'floating'
floatingPosition: {
top: '200px',
right: '20px'
}
};- Unique Tokens: 32-character random tokens for share URLs
- Expiration Control: Automatic expiration of shared links
- Privacy Settings: Public/private sharing options
- Customer Ownership: Users can only manage their own shares
- Token Validation: Secure token validation for access control
- CSRF Protection: Full CSRF token validation for API calls
- Database Indexing: Optimized indexes on frequently queried columns
- Eager Loading: Efficient relationship loading to prevent N+1 queries
- Caching: QR codes cached with appropriate headers
- Bulk Operations: Efficient bulk delete operations for cleanup
# 1. Install package
composer require theihasan/bagisto-wishlist-share
# 2. Publish and migrate
php artisan vendor:publish --provider="Ihasan\BagistoWishlistShare\Providers\WishlistShareServiceProvider"
php artisan migrate
# 3. Build assets
npm run build
# 4. Clear cache
php artisan config:clear && php artisan cache:clear
# 5. Test - Visit your wishlist page and look for the share button!- Package installed via Composer
- Migrations run successfully
- Assets published and compiled
- Share button appears on wishlist page
- Modal opens when clicking share button
- Admin menu shows "Wishlist Share" section
- Composer Installation Fails:
# Clear composer cache
composer clear-cache
# Update composer
composer self-update
# Install with verbose output
composer require theihasan/bagisto-wishlist-share -vvv- Migration Errors:
# Check if tables already exist
php artisan migrate:status
# Rollback if needed
php artisan migrate:rollback --step=2
# Re-run migrations
php artisan migrate- Asset Compilation Issues:
# Clear node modules
rm -rf node_modules package-lock.json
# Reinstall dependencies
npm install
# Build with verbose output
npm run build -- --verbose-
Share Modal Not Appearing:
- Check Assets: Ensure CSS/JS files are loaded
php artisan vendor:publish --tag=wishlist-share-assets --force npm run build
- Verify Blade Directives: Check if
@wishlistShareis included - Browser Console: Look for JavaScript errors
- Theme Compatibility: Ensure your theme supports the modal structure
-
QR Code Not Generating:
- Check Dependencies:
composer show endroid/qr-code
- PHP Extensions: Ensure GD or Imagick is installed
php -m | grep -i gd- File Permissions: Check temp directory permissions
chmod 755 storage/app/temp
-
Social Sharing Not Working:
- URL Encoding: Check if URLs are properly encoded
- HTTPS: Ensure your site uses HTTPS for social sharing
- Configuration: Verify social platform URLs in config
// config/wishlist-share.php 'social_platforms' => [ 'facebook' => [ 'enabled' => true, 'url' => 'https://www.facebook.com/sharer/sharer.php?u=', ], ]
-
Database Issues:
- Foreign Key Constraints: Ensure customer table exists
SHOW CREATE TABLE customers;
- Index Issues: Check if indexes are created properly
SHOW INDEX FROM wishlist_shares; -
Permission Issues:
- Admin Access: Check ACL permissions
php artisan cache:clear
- Customer Authentication: Verify customer guard is working
// Check in controller dd(auth('customer')->check());
- Package Not Auto-Loading:
# Regenerate autoload files
composer dump-autoload
# Clear application cache
php artisan config:clear
php artisan route:clear- Views Not Updating:
# Clear view cache
php artisan view:clear
# Re-publish views
php artisan vendor:publish --tag=wishlist-share-views --force- Routes Not Working:
# Check route list
php artisan route:list | grep wishlist-share
# Clear route cache
php artisan route:clearEnable debug mode for detailed error logging:
// config/wishlist-share.php
'debug' => env('WISHLIST_SHARE_DEBUG', false),# .env
WISHLIST_SHARE_DEBUG=true
APP_DEBUG=true-
Slow Loading:
- Enable query logging to identify N+1 queries
- Use eager loading for relationships
- Implement caching for frequently accessed data
-
Memory Issues:
- Increase PHP memory limit
- Optimize database queries
- Use pagination for large datasets
- Check Logs:
tail -f storage/logs/laravel.log- Enable Query Logging:
// In AppServiceProvider boot method
DB::listen(function ($query) {
Log::info($query->sql, $query->bindings);
});- Community Support:
- GitHub Issues: Report bugs and feature requests
- Bagisto Community: Ask questions in forums
- Stack Overflow: Tag questions with
bagistoandwishlist-share
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This package is licensed under the MIT License.
For support and bug reports, please create an issue in the package repository.
# Run tests
composer test
# Run tests with coverage
composer test-coverage
# Run specific test
vendor/bin/phpunit tests/Feature/WishlistShareTest.phpPlease see CONTRIBUTING for details.
If you discover a security vulnerability, please send an e-mail to ihasan@example.com. All security vulnerabilities will be promptly addressed.
Please see CHANGELOG for more information on what has changed recently.
- Initial release
- Core wishlist sharing functionality
- Social media integration
- QR code generation
- Admin analytics dashboard
- Comprehensive settings management