-
Notifications
You must be signed in to change notification settings - Fork 5
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
78 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import 'Vendor/rapidez/core/resources/js/vue' | ||
import amastybundles from './components/amastybundles.vue' | ||
import CrossSells from './components/CrossSells.vue' | ||
|
||
Vue.component('amastybundles', amastybundles) | ||
Vue.component('amasty-cross-sells', CrossSells) |
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,23 @@ | ||
<script> | ||
export default { | ||
render() { | ||
return this.$scopedSlots.default(this) | ||
}, | ||
data: () => ({ | ||
amastyIds: [] | ||
}), | ||
async mounted() { | ||
this.amastyIds = await rapidezAPI('post', 'cart/cross-sells', { | ||
ids: this.productIds | ||
}) | ||
}, | ||
computed: { | ||
productIds() { | ||
return this.$root.cart.items.map((item) => item.product.id) | ||
} | ||
} | ||
} | ||
</script> |
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,5 @@ | ||
<?php | ||
|
||
use Rapidez\AmastyAutomaticRelatedProducts\Http\Controllers\AmastyCrossSellController; | ||
|
||
Route::post('/api/cart/cross-sells', AmastyCrossSellController::class); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Rapidez\AmastyAutomaticRelatedProducts\Http\Controllers; | ||
|
||
|
||
use Illuminate\Http\Request; | ||
use Rapidez\AmastyAutomaticRelatedProducts\Models\AmastyCrossSells; | ||
|
||
class AmastyCrossSellController | ||
{ | ||
public function __invoke(Request $request): array|null | ||
{ | ||
$crossSellIds = AmastyCrossSells::whereIn('amasty_mostviewed_product_index.entity_id', $request->ids) | ||
->pluck('amasty_related_ids') | ||
->first(); | ||
|
||
return explode(',', $crossSellIds) ?? null; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Rapidez\AmastyAutomaticRelatedProducts\Models; | ||
|
||
use Illuminate\Database\Eloquent\Attributes\ScopedBy; | ||
use Rapidez\AmastyAutomaticRelatedProducts\Models\Scopes\CrossselProductsScope; | ||
use Rapidez\Core\Models\Model; | ||
|
||
#[ScopedBy([CrossselProductsScope::class])] | ||
class AmastyCrossSells extends Model | ||
{ | ||
protected $table = 'amasty_mostviewed_product_index'; | ||
} |
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