Compare commits
22 Commits
feat/ci-au
...
fix/auth-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fa9ea496c | ||
|
|
31756a2233 | ||
|
|
166583621b | ||
|
|
ca952c4674 | ||
|
|
4054778b6c | ||
|
|
56a5f00015 | ||
|
|
a96d50c481 | ||
|
|
4806212f46 | ||
|
|
2486f3c6b2 | ||
|
|
f25bebf6ee | ||
|
|
22dad6d0fc | ||
|
|
03eab66d35 | ||
|
|
97b1ab23d8 | ||
|
|
9fff0ba430 | ||
|
|
7d3e91b2e6 | ||
|
|
74957a9ec5 | ||
|
|
2d035c46cf | ||
|
|
53445fe72a | ||
|
|
37cc8956c5 | ||
|
|
2c52493a9c | ||
|
|
bafcf1694a | ||
|
|
38ae2c3a3e |
@@ -89,7 +89,11 @@ steps:
|
|||||||
from_secret: registry_password
|
from_secret: registry_password
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
provenance: false
|
provenance: false
|
||||||
build_args: APP_BUILD_VERSION=${CI_COMMIT_SHA:0:8},APP_GIT_SHA=${CI_COMMIT_SHA},APP_BUILD_TIME=${CI_PIPELINE_CREATED},CONTAINER_IMAGE_TAG=${CI_COMMIT_SHA:0:8}
|
build_args:
|
||||||
|
APP_BUILD_VERSION: ${CI_COMMIT_SHA:0:8}
|
||||||
|
APP_GIT_SHA: ${CI_COMMIT_SHA}
|
||||||
|
APP_BUILD_TIME: ${CI_PIPELINE_CREATED}
|
||||||
|
CONTAINER_IMAGE_TAG: ${CI_COMMIT_SHA:0:8}
|
||||||
depends_on: []
|
depends_on: []
|
||||||
when:
|
when:
|
||||||
branch: master
|
branch: master
|
||||||
|
|||||||
394
backend/docs/BRAND_INTELLIGENCE_API.md
Normal file
394
backend/docs/BRAND_INTELLIGENCE_API.md
Normal file
@@ -0,0 +1,394 @@
|
|||||||
|
# Brand Intelligence API
|
||||||
|
|
||||||
|
## Endpoint
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /api/analytics/v2/brand/:name/intelligence
|
||||||
|
```
|
||||||
|
|
||||||
|
## Query Parameters
|
||||||
|
|
||||||
|
| Param | Type | Default | Description |
|
||||||
|
|-------|------|---------|-------------|
|
||||||
|
| `window` | `7d\|30d\|90d` | `30d` | Time window for trend calculations |
|
||||||
|
| `state` | string | - | Filter by state code (e.g., `AZ`) |
|
||||||
|
| `category` | string | - | Filter by category (e.g., `Flower`) |
|
||||||
|
|
||||||
|
## Response Payload Schema
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface BrandIntelligenceResult {
|
||||||
|
brand_name: string;
|
||||||
|
window: '7d' | '30d' | '90d';
|
||||||
|
generated_at: string; // ISO timestamp when data was computed
|
||||||
|
|
||||||
|
performance_snapshot: PerformanceSnapshot;
|
||||||
|
alerts: Alerts;
|
||||||
|
sku_performance: SkuPerformance[];
|
||||||
|
retail_footprint: RetailFootprint;
|
||||||
|
competitive_landscape: CompetitiveLandscape;
|
||||||
|
inventory_health: InventoryHealth;
|
||||||
|
promo_performance: PromoPerformance;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 1: Performance Snapshot
|
||||||
|
|
||||||
|
Summary cards with key brand metrics.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface PerformanceSnapshot {
|
||||||
|
active_skus: number; // Total products in catalog
|
||||||
|
total_revenue_30d: number | null; // Estimated from qty × price
|
||||||
|
total_stores: number; // Active retail partners
|
||||||
|
new_stores_30d: number; // New distribution in window
|
||||||
|
market_share: number | null; // % of category SKUs
|
||||||
|
avg_wholesale_price: number | null;
|
||||||
|
price_position: 'premium' | 'value' | 'competitive';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label | Helper Text |
|
||||||
|
|-------|-------------------|-------------|
|
||||||
|
| `active_skus` | Active Products | X total in catalog |
|
||||||
|
| `total_revenue_30d` | Monthly Revenue | Estimated from sales |
|
||||||
|
| `total_stores` | Retail Distribution | Active retail partners |
|
||||||
|
| `new_stores_30d` | New Opportunities | X new in last 30 days |
|
||||||
|
| `market_share` | Category Position | % of category |
|
||||||
|
| `avg_wholesale_price` | Avg Wholesale | Per unit |
|
||||||
|
| `price_position` | Pricing Tier | Premium/Value/Market Rate |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 2: Alerts
|
||||||
|
|
||||||
|
Issues requiring attention.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface Alerts {
|
||||||
|
lost_stores_30d_count: number;
|
||||||
|
lost_skus_30d_count: number;
|
||||||
|
competitor_takeover_count: number;
|
||||||
|
avg_oos_duration_days: number | null;
|
||||||
|
avg_reorder_lag_days: number | null;
|
||||||
|
items: AlertItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AlertItem {
|
||||||
|
type: 'lost_store' | 'delisted_sku' | 'shelf_loss' | 'extended_oos';
|
||||||
|
severity: 'critical' | 'warning';
|
||||||
|
store_name?: string;
|
||||||
|
product_name?: string;
|
||||||
|
competitor_brand?: string;
|
||||||
|
days_since?: number;
|
||||||
|
state_code?: string;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `lost_stores_30d_count` | Accounts at Risk |
|
||||||
|
| `lost_skus_30d_count` | Delisted SKUs |
|
||||||
|
| `competitor_takeover_count` | Shelf Losses |
|
||||||
|
| `avg_oos_duration_days` | Avg Stockout Length |
|
||||||
|
| `avg_reorder_lag_days` | Avg Restock Time |
|
||||||
|
| `severity: critical` | Urgent |
|
||||||
|
| `severity: warning` | Watch |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 3: SKU Performance (Product Velocity)
|
||||||
|
|
||||||
|
How fast each SKU sells.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface SkuPerformance {
|
||||||
|
store_product_id: number;
|
||||||
|
product_name: string;
|
||||||
|
category: string | null;
|
||||||
|
daily_velocity: number; // Units/day estimate
|
||||||
|
velocity_status: 'hot' | 'steady' | 'slow' | 'stale';
|
||||||
|
retail_price: number | null;
|
||||||
|
on_sale: boolean;
|
||||||
|
stores_carrying: number;
|
||||||
|
stock_status: 'in_stock' | 'low_stock' | 'out_of_stock';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `daily_velocity` | Daily Rate |
|
||||||
|
| `velocity_status` | Momentum |
|
||||||
|
| `velocity_status: hot` | Hot |
|
||||||
|
| `velocity_status: steady` | Steady |
|
||||||
|
| `velocity_status: slow` | Slow |
|
||||||
|
| `velocity_status: stale` | Stale |
|
||||||
|
| `retail_price` | Retail Price |
|
||||||
|
| `on_sale` | Promo (badge) |
|
||||||
|
|
||||||
|
**Velocity Thresholds:**
|
||||||
|
- `hot`: >= 5 units/day
|
||||||
|
- `steady`: >= 1 unit/day
|
||||||
|
- `slow`: >= 0.1 units/day
|
||||||
|
- `stale`: < 0.1 units/day
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 4: Retail Footprint
|
||||||
|
|
||||||
|
Store placement and coverage.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface RetailFootprint {
|
||||||
|
total_stores: number;
|
||||||
|
in_stock_count: number;
|
||||||
|
out_of_stock_count: number;
|
||||||
|
penetration_by_region: RegionPenetration[];
|
||||||
|
whitespace_stores: WhitespaceStore[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RegionPenetration {
|
||||||
|
state_code: string;
|
||||||
|
store_count: number;
|
||||||
|
percent_reached: number; // % of state's dispensaries
|
||||||
|
in_stock: number;
|
||||||
|
out_of_stock: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WhitespaceStore {
|
||||||
|
store_id: number;
|
||||||
|
store_name: string;
|
||||||
|
state_code: string;
|
||||||
|
city: string | null;
|
||||||
|
category_fit: number; // How many competing brands they carry
|
||||||
|
competitor_brands: string[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `penetration_by_region` | Market Coverage by Region |
|
||||||
|
| `percent_reached` | X% reached |
|
||||||
|
| `in_stock` | X stocked |
|
||||||
|
| `out_of_stock` | X out |
|
||||||
|
| `whitespace_stores` | Expansion Opportunities |
|
||||||
|
| `category_fit` | X fit |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 5: Competitive Landscape
|
||||||
|
|
||||||
|
Market positioning vs competitors.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface CompetitiveLandscape {
|
||||||
|
brand_price_position: 'premium' | 'value' | 'competitive';
|
||||||
|
market_share_trend: MarketSharePoint[];
|
||||||
|
competitors: Competitor[];
|
||||||
|
head_to_head_skus: HeadToHead[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MarketSharePoint {
|
||||||
|
date: string;
|
||||||
|
share_percent: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Competitor {
|
||||||
|
brand_name: string;
|
||||||
|
store_overlap_percent: number;
|
||||||
|
price_position: 'premium' | 'value' | 'competitive';
|
||||||
|
avg_price: number | null;
|
||||||
|
sku_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HeadToHead {
|
||||||
|
product_name: string;
|
||||||
|
brand_price: number;
|
||||||
|
competitor_brand: string;
|
||||||
|
competitor_price: number;
|
||||||
|
price_diff_percent: number;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `price_position: premium` | Premium Tier |
|
||||||
|
| `price_position: value` | Value Leader |
|
||||||
|
| `price_position: competitive` | Market Rate |
|
||||||
|
| `market_share_trend` | Share of Shelf Trend |
|
||||||
|
| `head_to_head_skus` | Price Comparison |
|
||||||
|
| `store_overlap_percent` | X% store overlap |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 6: Inventory Health
|
||||||
|
|
||||||
|
Stock projections and risk levels.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface InventoryHealth {
|
||||||
|
critical_count: number; // <7 days stock
|
||||||
|
warning_count: number; // 7-14 days stock
|
||||||
|
healthy_count: number; // 14-90 days stock
|
||||||
|
overstocked_count: number; // >90 days stock
|
||||||
|
skus: InventorySku[];
|
||||||
|
overstock_alert: OverstockItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InventorySku {
|
||||||
|
store_product_id: number;
|
||||||
|
product_name: string;
|
||||||
|
store_name: string;
|
||||||
|
days_of_stock: number | null;
|
||||||
|
risk_level: 'critical' | 'elevated' | 'moderate' | 'healthy';
|
||||||
|
current_quantity: number | null;
|
||||||
|
daily_sell_rate: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OverstockItem {
|
||||||
|
product_name: string;
|
||||||
|
store_name: string;
|
||||||
|
excess_units: number;
|
||||||
|
days_of_stock: number;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `risk_level: critical` | Reorder Now |
|
||||||
|
| `risk_level: elevated` | Low Stock |
|
||||||
|
| `risk_level: moderate` | Monitor |
|
||||||
|
| `risk_level: healthy` | Healthy |
|
||||||
|
| `critical_count` | Urgent (<7 days) |
|
||||||
|
| `warning_count` | Low (7-14 days) |
|
||||||
|
| `overstocked_count` | Excess (>90 days) |
|
||||||
|
| `days_of_stock` | X days remaining |
|
||||||
|
| `overstock_alert` | Overstock Alert |
|
||||||
|
| `excess_units` | X excess units |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Section 7: Promotion Effectiveness
|
||||||
|
|
||||||
|
How promotions impact sales.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface PromoPerformance {
|
||||||
|
avg_baseline_velocity: number | null;
|
||||||
|
avg_promo_velocity: number | null;
|
||||||
|
avg_velocity_lift: number | null; // % increase during promo
|
||||||
|
avg_efficiency_score: number | null; // ROI proxy
|
||||||
|
promotions: Promotion[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Promotion {
|
||||||
|
product_name: string;
|
||||||
|
store_name: string;
|
||||||
|
status: 'active' | 'scheduled' | 'ended';
|
||||||
|
start_date: string;
|
||||||
|
end_date: string | null;
|
||||||
|
regular_price: number;
|
||||||
|
promo_price: number;
|
||||||
|
discount_percent: number;
|
||||||
|
baseline_velocity: number | null;
|
||||||
|
promo_velocity: number | null;
|
||||||
|
velocity_lift: number | null;
|
||||||
|
efficiency_score: number | null;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**UI Label Mapping:**
|
||||||
|
| Field | User-Facing Label |
|
||||||
|
|-------|-------------------|
|
||||||
|
| `avg_baseline_velocity` | Normal Rate |
|
||||||
|
| `avg_promo_velocity` | During Promos |
|
||||||
|
| `avg_velocity_lift` | Avg Sales Lift |
|
||||||
|
| `avg_efficiency_score` | ROI Score |
|
||||||
|
| `velocity_lift` | Sales Lift |
|
||||||
|
| `efficiency_score` | ROI Score |
|
||||||
|
| `status: active` | Live |
|
||||||
|
| `status: scheduled` | Scheduled |
|
||||||
|
| `status: ended` | Ended |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Example Queries
|
||||||
|
|
||||||
|
### Get full payload
|
||||||
|
```javascript
|
||||||
|
const response = await fetch('/api/analytics/v2/brand/Wyld/intelligence?window=30d');
|
||||||
|
const data = await response.json();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extract summary cards (flattened)
|
||||||
|
```javascript
|
||||||
|
const { performance_snapshot: ps, alerts } = data;
|
||||||
|
|
||||||
|
const summaryCards = {
|
||||||
|
activeProducts: ps.active_skus,
|
||||||
|
monthlyRevenue: ps.total_revenue_30d,
|
||||||
|
retailDistribution: ps.total_stores,
|
||||||
|
newOpportunities: ps.new_stores_30d,
|
||||||
|
categoryPosition: ps.market_share,
|
||||||
|
avgWholesale: ps.avg_wholesale_price,
|
||||||
|
pricingTier: ps.price_position,
|
||||||
|
accountsAtRisk: alerts.lost_stores_30d_count,
|
||||||
|
delistedSkus: alerts.lost_skus_30d_count,
|
||||||
|
shelfLosses: alerts.competitor_takeover_count,
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get top 10 fastest selling SKUs
|
||||||
|
```javascript
|
||||||
|
const topSkus = data.sku_performance
|
||||||
|
.filter(sku => sku.velocity_status === 'hot' || sku.velocity_status === 'steady')
|
||||||
|
.sort((a, b) => b.daily_velocity - a.daily_velocity)
|
||||||
|
.slice(0, 10);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get critical inventory alerts only
|
||||||
|
```javascript
|
||||||
|
const criticalInventory = data.inventory_health.skus
|
||||||
|
.filter(sku => sku.risk_level === 'critical');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get states with <50% penetration
|
||||||
|
```javascript
|
||||||
|
const underPenetrated = data.retail_footprint.penetration_by_region
|
||||||
|
.filter(region => region.percent_reached < 50)
|
||||||
|
.sort((a, b) => a.percent_reached - b.percent_reached);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get active promotions with positive lift
|
||||||
|
```javascript
|
||||||
|
const effectivePromos = data.promo_performance.promotions
|
||||||
|
.filter(p => p.status === 'active' && p.velocity_lift > 0)
|
||||||
|
.sort((a, b) => b.velocity_lift - a.velocity_lift);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build chart data for market share trend
|
||||||
|
```javascript
|
||||||
|
const chartData = data.competitive_landscape.market_share_trend.map(point => ({
|
||||||
|
x: new Date(point.date),
|
||||||
|
y: point.share_percent,
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notes for Frontend Implementation
|
||||||
|
|
||||||
|
1. **All fields are snake_case** - transform to camelCase if needed
|
||||||
|
2. **Null values are possible** - handle gracefully in UI
|
||||||
|
3. **Arrays may be empty** - show appropriate empty states
|
||||||
|
4. **Timestamps are ISO format** - parse with `new Date()`
|
||||||
|
5. **Percentages are already computed** - no need to multiply by 100
|
||||||
|
6. **The `window` parameter affects trend calculations** - 7d/30d/90d
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dutchie-menus-backend",
|
"name": "dutchie-menus-backend",
|
||||||
"version": "1.5.1",
|
"version": "1.6.0",
|
||||||
"description": "Backend API for Dutchie Menus scraper and management",
|
"description": "Backend API for Dutchie Menus scraper and management",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
BIN
backend/public/downloads/cannaiq-menus-1.6.0.zip
Normal file
BIN
backend/public/downloads/cannaiq-menus-1.6.0.zip
Normal file
Binary file not shown.
1
backend/public/downloads/cannaiq-menus-latest.zip
Symbolic link
1
backend/public/downloads/cannaiq-menus-latest.zip
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
cannaiq-menus-1.6.0.zip
|
||||||
@@ -32,6 +32,7 @@ const TRUSTED_ORIGINS = [
|
|||||||
// Pattern-based trusted origins (wildcards)
|
// Pattern-based trusted origins (wildcards)
|
||||||
const TRUSTED_ORIGIN_PATTERNS = [
|
const TRUSTED_ORIGIN_PATTERNS = [
|
||||||
/^https:\/\/.*\.cannabrands\.app$/, // *.cannabrands.app
|
/^https:\/\/.*\.cannabrands\.app$/, // *.cannabrands.app
|
||||||
|
/^https:\/\/.*\.cannaiq\.co$/, // *.cannaiq.co
|
||||||
];
|
];
|
||||||
|
|
||||||
// Trusted IPs for internal pod-to-pod communication
|
// Trusted IPs for internal pod-to-pod communication
|
||||||
@@ -152,22 +153,10 @@ export async function authenticateUser(email: string, password: string): Promise
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function authMiddleware(req: AuthRequest, res: Response, next: NextFunction) {
|
export async function authMiddleware(req: AuthRequest, res: Response, next: NextFunction) {
|
||||||
// Allow trusted origins/IPs to bypass auth (internal services, same-origin)
|
|
||||||
if (isTrustedRequest(req)) {
|
|
||||||
req.user = {
|
|
||||||
id: 0,
|
|
||||||
email: 'internal@system',
|
|
||||||
role: 'internal'
|
|
||||||
};
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
const authHeader = req.headers.authorization;
|
const authHeader = req.headers.authorization;
|
||||||
|
|
||||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
// If a Bearer token is provided, always try to use it first (logged-in user)
|
||||||
return res.status(401).json({ error: 'No token provided' });
|
if (authHeader && authHeader.startsWith('Bearer ')) {
|
||||||
}
|
|
||||||
|
|
||||||
const token = authHeader.substring(7);
|
const token = authHeader.substring(7);
|
||||||
|
|
||||||
// Try JWT first
|
// Try JWT first
|
||||||
@@ -186,56 +175,44 @@ export async function authMiddleware(req: AuthRequest, res: Response, next: Next
|
|||||||
WHERE token = $1
|
WHERE token = $1
|
||||||
`, [token]);
|
`, [token]);
|
||||||
|
|
||||||
if (result.rows.length === 0) {
|
if (result.rows.length > 0) {
|
||||||
|
const apiToken = result.rows[0];
|
||||||
|
if (!apiToken.active) {
|
||||||
|
return res.status(401).json({ error: 'API token is inactive' });
|
||||||
|
}
|
||||||
|
if (apiToken.expires_at && new Date(apiToken.expires_at) < new Date()) {
|
||||||
|
return res.status(401).json({ error: 'API token has expired' });
|
||||||
|
}
|
||||||
|
req.user = {
|
||||||
|
id: 0,
|
||||||
|
email: `api:${apiToken.name}`,
|
||||||
|
role: 'api_token'
|
||||||
|
};
|
||||||
|
req.apiToken = apiToken;
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('API token lookup error:', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Token provided but invalid
|
||||||
return res.status(401).json({ error: 'Invalid token' });
|
return res.status(401).json({ error: 'Invalid token' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiToken = result.rows[0];
|
// No token provided - check trusted origins for API access (WordPress, etc.)
|
||||||
|
if (isTrustedRequest(req)) {
|
||||||
// Check if token is active
|
|
||||||
if (!apiToken.active) {
|
|
||||||
return res.status(401).json({ error: 'Token is disabled' });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if token is expired
|
|
||||||
if (apiToken.expires_at && new Date(apiToken.expires_at) < new Date()) {
|
|
||||||
return res.status(401).json({ error: 'Token has expired' });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check allowed endpoints
|
|
||||||
if (apiToken.allowed_endpoints && apiToken.allowed_endpoints.length > 0) {
|
|
||||||
const isAllowed = apiToken.allowed_endpoints.some((pattern: string) => {
|
|
||||||
// Simple wildcard matching
|
|
||||||
const regex = new RegExp('^' + pattern.replace('*', '.*') + '$');
|
|
||||||
return regex.test(req.path);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!isAllowed) {
|
|
||||||
return res.status(403).json({ error: 'Endpoint not allowed for this token' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set API token on request for tracking
|
|
||||||
req.apiToken = {
|
|
||||||
id: apiToken.id,
|
|
||||||
name: apiToken.name,
|
|
||||||
rate_limit: apiToken.rate_limit
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set a generic user for compatibility with existing code
|
|
||||||
req.user = {
|
req.user = {
|
||||||
id: apiToken.id,
|
id: 0,
|
||||||
email: `api-token-${apiToken.id}@system`,
|
email: 'internal@system',
|
||||||
role: 'api'
|
role: 'internal'
|
||||||
};
|
};
|
||||||
|
return next();
|
||||||
next();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error verifying API token:', error);
|
|
||||||
return res.status(500).json({ error: 'Authentication failed' });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res.status(401).json({ error: 'No token provided' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Require specific role(s) to access endpoint.
|
* Require specific role(s) to access endpoint.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { Request, Response, NextFunction } from 'express';
|
|||||||
* These are our own frontends that should have unrestricted access.
|
* These are our own frontends that should have unrestricted access.
|
||||||
*/
|
*/
|
||||||
const TRUSTED_DOMAINS = [
|
const TRUSTED_DOMAINS = [
|
||||||
'cannaiq.co',
|
'*.cannaiq.co',
|
||||||
'www.cannaiq.co',
|
'*.cannabrands.app',
|
||||||
'findagram.co',
|
'findagram.co',
|
||||||
'www.findagram.co',
|
'www.findagram.co',
|
||||||
'findadispo.com',
|
'findadispo.com',
|
||||||
@@ -32,6 +32,24 @@ function extractDomain(header: string): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a domain matches any trusted domain (supports *.domain.com wildcards)
|
||||||
|
*/
|
||||||
|
function isTrustedDomain(domain: string): boolean {
|
||||||
|
for (const trusted of TRUSTED_DOMAINS) {
|
||||||
|
if (trusted.startsWith('*.')) {
|
||||||
|
// Wildcard: *.example.com matches example.com and any subdomain
|
||||||
|
const baseDomain = trusted.slice(2);
|
||||||
|
if (domain === baseDomain || domain.endsWith('.' + baseDomain)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (domain === trusted) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the request comes from a trusted domain
|
* Checks if the request comes from a trusted domain
|
||||||
*/
|
*/
|
||||||
@@ -42,7 +60,7 @@ function isRequestFromTrustedDomain(req: Request): boolean {
|
|||||||
// Check Origin header first (preferred for CORS requests)
|
// Check Origin header first (preferred for CORS requests)
|
||||||
if (origin) {
|
if (origin) {
|
||||||
const domain = extractDomain(origin);
|
const domain = extractDomain(origin);
|
||||||
if (domain && TRUSTED_DOMAINS.includes(domain)) {
|
if (domain && isTrustedDomain(domain)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +68,7 @@ function isRequestFromTrustedDomain(req: Request): boolean {
|
|||||||
// Fallback to Referer header
|
// Fallback to Referer header
|
||||||
if (referer) {
|
if (referer) {
|
||||||
const domain = extractDomain(referer);
|
const domain = extractDomain(referer);
|
||||||
if (domain && TRUSTED_DOMAINS.includes(domain)) {
|
if (domain && isTrustedDomain(domain)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { BrandPenetrationService } from '../services/analytics/BrandPenetrationS
|
|||||||
import { CategoryAnalyticsService } from '../services/analytics/CategoryAnalyticsService';
|
import { CategoryAnalyticsService } from '../services/analytics/CategoryAnalyticsService';
|
||||||
import { StoreAnalyticsService } from '../services/analytics/StoreAnalyticsService';
|
import { StoreAnalyticsService } from '../services/analytics/StoreAnalyticsService';
|
||||||
import { StateAnalyticsService } from '../services/analytics/StateAnalyticsService';
|
import { StateAnalyticsService } from '../services/analytics/StateAnalyticsService';
|
||||||
|
import { BrandIntelligenceService } from '../services/analytics/BrandIntelligenceService';
|
||||||
import { TimeWindow, LegalType } from '../services/analytics/types';
|
import { TimeWindow, LegalType } from '../services/analytics/types';
|
||||||
|
|
||||||
function parseTimeWindow(window?: string): TimeWindow {
|
function parseTimeWindow(window?: string): TimeWindow {
|
||||||
@@ -41,6 +42,7 @@ export function createAnalyticsV2Router(pool: Pool): Router {
|
|||||||
const categoryService = new CategoryAnalyticsService(pool);
|
const categoryService = new CategoryAnalyticsService(pool);
|
||||||
const storeService = new StoreAnalyticsService(pool);
|
const storeService = new StoreAnalyticsService(pool);
|
||||||
const stateService = new StateAnalyticsService(pool);
|
const stateService = new StateAnalyticsService(pool);
|
||||||
|
const brandIntelligenceService = new BrandIntelligenceService(pool);
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// PRICE ANALYTICS
|
// PRICE ANALYTICS
|
||||||
@@ -259,6 +261,48 @@ export function createAnalyticsV2Router(pool: Pool): Router {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /brand/:name/intelligence
|
||||||
|
* Get comprehensive B2B brand intelligence dashboard data
|
||||||
|
*
|
||||||
|
* Returns all brand metrics in a single unified response:
|
||||||
|
* - Performance Snapshot (active SKUs, revenue, stores, market share)
|
||||||
|
* - Alerts/Slippage (lost stores, delisted SKUs, competitor takeovers)
|
||||||
|
* - Product Velocity (daily rates, velocity status)
|
||||||
|
* - Retail Footprint (penetration, whitespace opportunities)
|
||||||
|
* - Competitive Landscape (price position, market share trend)
|
||||||
|
* - Inventory Health (days of stock, risk levels)
|
||||||
|
* - Promotion Effectiveness (baseline vs promo velocity, ROI)
|
||||||
|
*
|
||||||
|
* Query params:
|
||||||
|
* - window: 7d|30d|90d (default: 30d)
|
||||||
|
* - state: state code filter (e.g., AZ)
|
||||||
|
* - category: category filter (e.g., Flower)
|
||||||
|
*/
|
||||||
|
router.get('/brand/:name/intelligence', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
const brandName = decodeURIComponent(req.params.name);
|
||||||
|
const window = parseTimeWindow(req.query.window as string);
|
||||||
|
const stateCode = req.query.state as string | undefined;
|
||||||
|
const category = req.query.category as string | undefined;
|
||||||
|
|
||||||
|
const result = await brandIntelligenceService.getBrandIntelligence(brandName, {
|
||||||
|
window,
|
||||||
|
stateCode,
|
||||||
|
category,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return res.status(404).json({ error: 'Brand not found' });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[AnalyticsV2] Brand intelligence error:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to fetch brand intelligence' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// CATEGORY ANALYTICS
|
// CATEGORY ANALYTICS
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ const CONSUMER_TRUSTED_ORIGINS = [
|
|||||||
'http://localhost:3002',
|
'http://localhost:3002',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Wildcard trusted origin patterns (*.domain.com)
|
||||||
|
const CONSUMER_TRUSTED_PATTERNS = [
|
||||||
|
/^https:\/\/([a-z0-9-]+\.)?cannaiq\.co$/,
|
||||||
|
/^https:\/\/([a-z0-9-]+\.)?cannabrands\.app$/,
|
||||||
|
];
|
||||||
|
|
||||||
// Trusted IPs for local development (bypass API key auth)
|
// Trusted IPs for local development (bypass API key auth)
|
||||||
const TRUSTED_IPS = ['127.0.0.1', '::1', '::ffff:127.0.0.1'];
|
const TRUSTED_IPS = ['127.0.0.1', '::1', '::ffff:127.0.0.1'];
|
||||||
|
|
||||||
@@ -150,9 +156,18 @@ function isConsumerTrustedRequest(req: Request): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const origin = req.headers.origin;
|
const origin = req.headers.origin;
|
||||||
if (origin && CONSUMER_TRUSTED_ORIGINS.includes(origin)) {
|
if (origin) {
|
||||||
|
// Check exact matches
|
||||||
|
if (CONSUMER_TRUSTED_ORIGINS.includes(origin)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Check wildcard patterns
|
||||||
|
for (const pattern of CONSUMER_TRUSTED_PATTERNS) {
|
||||||
|
if (pattern.test(origin)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const referer = req.headers.referer;
|
const referer = req.headers.referer;
|
||||||
if (referer) {
|
if (referer) {
|
||||||
for (const trusted of CONSUMER_TRUSTED_ORIGINS) {
|
for (const trusted of CONSUMER_TRUSTED_ORIGINS) {
|
||||||
@@ -160,6 +175,18 @@ function isConsumerTrustedRequest(req: Request): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check wildcard patterns against referer origin
|
||||||
|
try {
|
||||||
|
const refererUrl = new URL(referer);
|
||||||
|
const refererOrigin = refererUrl.origin;
|
||||||
|
for (const pattern of CONSUMER_TRUSTED_PATTERNS) {
|
||||||
|
if (pattern.test(refererOrigin)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Invalid referer URL, ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
1202
backend/src/services/analytics/BrandIntelligenceService.ts
Normal file
1202
backend/src/services/analytics/BrandIntelligenceService.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -75,7 +75,7 @@ export class BrandPenetrationService {
|
|||||||
DATE(sps.captured_at) AS date,
|
DATE(sps.captured_at) AS date,
|
||||||
COUNT(DISTINCT sps.dispensary_id) AS dispensary_count
|
COUNT(DISTINCT sps.dispensary_id) AS dispensary_count
|
||||||
FROM store_product_snapshots sps
|
FROM store_product_snapshots sps
|
||||||
WHERE sps.brand_name = $1
|
WHERE sps.brand_name_raw = $1
|
||||||
AND sps.captured_at >= $2
|
AND sps.captured_at >= $2
|
||||||
AND sps.captured_at <= $3
|
AND sps.captured_at <= $3
|
||||||
AND sps.is_in_stock = TRUE
|
AND sps.is_in_stock = TRUE
|
||||||
@@ -368,23 +368,23 @@ export class BrandPenetrationService {
|
|||||||
const result = await this.pool.query(`
|
const result = await this.pool.query(`
|
||||||
WITH start_counts AS (
|
WITH start_counts AS (
|
||||||
SELECT
|
SELECT
|
||||||
brand_name,
|
brand_name_raw AS brand_name,
|
||||||
COUNT(DISTINCT dispensary_id) AS dispensary_count
|
COUNT(DISTINCT dispensary_id) AS dispensary_count
|
||||||
FROM store_product_snapshots
|
FROM store_product_snapshots
|
||||||
WHERE captured_at >= $1 AND captured_at < $1 + INTERVAL '1 day'
|
WHERE captured_at >= $1 AND captured_at < $1 + INTERVAL '1 day'
|
||||||
AND brand_name IS NOT NULL
|
AND brand_name_raw IS NOT NULL
|
||||||
AND is_in_stock = TRUE
|
AND is_in_stock = TRUE
|
||||||
GROUP BY brand_name
|
GROUP BY brand_name_raw
|
||||||
),
|
),
|
||||||
end_counts AS (
|
end_counts AS (
|
||||||
SELECT
|
SELECT
|
||||||
brand_name,
|
brand_name_raw AS brand_name,
|
||||||
COUNT(DISTINCT dispensary_id) AS dispensary_count
|
COUNT(DISTINCT dispensary_id) AS dispensary_count
|
||||||
FROM store_product_snapshots
|
FROM store_product_snapshots
|
||||||
WHERE captured_at >= $2 - INTERVAL '1 day' AND captured_at <= $2
|
WHERE captured_at >= $2 - INTERVAL '1 day' AND captured_at <= $2
|
||||||
AND brand_name IS NOT NULL
|
AND brand_name_raw IS NOT NULL
|
||||||
AND is_in_stock = TRUE
|
AND is_in_stock = TRUE
|
||||||
GROUP BY brand_name
|
GROUP BY brand_name_raw
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
COALESCE(sc.brand_name, ec.brand_name) AS brand_name,
|
COALESCE(sc.brand_name, ec.brand_name) AS brand_name,
|
||||||
|
|||||||
@@ -11,3 +11,4 @@ export { BrandPenetrationService } from './BrandPenetrationService';
|
|||||||
export { CategoryAnalyticsService } from './CategoryAnalyticsService';
|
export { CategoryAnalyticsService } from './CategoryAnalyticsService';
|
||||||
export { StoreAnalyticsService } from './StoreAnalyticsService';
|
export { StoreAnalyticsService } from './StoreAnalyticsService';
|
||||||
export { StateAnalyticsService } from './StateAnalyticsService';
|
export { StateAnalyticsService } from './StateAnalyticsService';
|
||||||
|
export { BrandIntelligenceService } from './BrandIntelligenceService';
|
||||||
|
|||||||
@@ -7,16 +7,6 @@
|
|||||||
"src": "favicon.ico",
|
"src": "favicon.ico",
|
||||||
"sizes": "64x64 32x32 24x24 16x16",
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
"type": "image/x-icon"
|
"type": "image/x-icon"
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "logo192.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "192x192"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "logo512.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "512x512"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
|
|||||||
@@ -373,10 +373,12 @@ export function mapCategoryForUI(apiCategory) {
|
|||||||
* Map API brand to UI-compatible format
|
* Map API brand to UI-compatible format
|
||||||
*/
|
*/
|
||||||
export function mapBrandForUI(apiBrand) {
|
export function mapBrandForUI(apiBrand) {
|
||||||
|
// API returns 'brand' field (see /api/v1/brands endpoint)
|
||||||
|
const brandName = apiBrand.brand || apiBrand.brand_name || '';
|
||||||
return {
|
return {
|
||||||
id: apiBrand.brand_name,
|
id: brandName,
|
||||||
name: apiBrand.brand_name,
|
name: brandName,
|
||||||
slug: apiBrand.brand_name?.toLowerCase().replace(/\s+/g, '-'),
|
slug: brandName ? brandName.toLowerCase().replace(/\s+/g, '-') : '',
|
||||||
logo: apiBrand.brand_logo_url || null,
|
logo: apiBrand.brand_logo_url || null,
|
||||||
productCount: parseInt(apiBrand.product_count || 0, 10),
|
productCount: parseInt(apiBrand.product_count || 0, 10),
|
||||||
dispensaryCount: parseInt(apiBrand.dispensary_count || 0, 10),
|
dispensaryCount: parseInt(apiBrand.dispensary_count || 0, 10),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const Brands = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const filteredBrands = brands.filter((brand) =>
|
const filteredBrands = brands.filter((brand) =>
|
||||||
brand.name.toLowerCase().includes(searchQuery.toLowerCase())
|
brand.name && brand.name.toLowerCase().includes(searchQuery.toLowerCase())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Group brands alphabetically
|
// Group brands alphabetically
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.5.4
|
1.6.0
|
||||||
|
|||||||
@@ -312,3 +312,184 @@
|
|||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border-left: 4px solid #c62828;
|
border-left: 4px solid #c62828;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================
|
||||||
|
Brand Grid Widget
|
||||||
|
======================================== */
|
||||||
|
.cannaiq-brand-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 20px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-brand-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-brand-card:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-brand-name {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-brand-count {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========================================
|
||||||
|
Category List Widget
|
||||||
|
======================================== */
|
||||||
|
.cannaiq-category-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-pills {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 12px 16px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #333;
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
||||||
|
transition: background 0.2s, transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-item:hover {
|
||||||
|
background: #f3f4f6;
|
||||||
|
transform: translateX(4px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-pills-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
background: #f3f4f6;
|
||||||
|
border-radius: 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #333;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-pills-item:hover {
|
||||||
|
background: #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-name {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-category-count {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========================================
|
||||||
|
Specials/Deals Grid Widget
|
||||||
|
======================================== */
|
||||||
|
.cannaiq-specials-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 24px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-card:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-discount-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: 12px;
|
||||||
|
right: 12px;
|
||||||
|
background: #ef4444;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-image {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-image img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-content {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-price {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-price .cannaiq-price-sale {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #16a34a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cannaiq-special-price .cannaiq-price-regular {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: CannaIQ Menus
|
* Plugin Name: CannaIQ Menus
|
||||||
* Plugin URI: https://cannaiq.co
|
* Plugin URI: https://cannaiq.co
|
||||||
* Description: Display cannabis product menus from CannaIQ with Elementor integration. Real-time menu data updated daily.
|
* Description: Display cannabis product menus from CannaIQ with Elementor integration. Real-time menu data updated daily.
|
||||||
* Version: 1.5.4
|
* Version: 1.6.0
|
||||||
* Author: CannaIQ
|
* Author: CannaIQ
|
||||||
* Author URI: https://cannaiq.co
|
* Author URI: https://cannaiq.co
|
||||||
* License: GPL v2 or later
|
* License: GPL v2 or later
|
||||||
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
|
|||||||
exit; // Exit if accessed directly
|
exit; // Exit if accessed directly
|
||||||
}
|
}
|
||||||
|
|
||||||
define('CANNAIQ_MENUS_VERSION', '1.5.4');
|
define('CANNAIQ_MENUS_VERSION', '1.6.0');
|
||||||
define('CANNAIQ_MENUS_API_URL', 'https://cannaiq.co/api/v1');
|
define('CANNAIQ_MENUS_API_URL', 'https://cannaiq.co/api/v1');
|
||||||
define('CANNAIQ_MENUS_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
define('CANNAIQ_MENUS_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||||
define('CANNAIQ_MENUS_PLUGIN_URL', plugin_dir_url(__FILE__));
|
define('CANNAIQ_MENUS_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||||
@@ -46,14 +46,17 @@ class CannaIQ_Menus_Plugin {
|
|||||||
// Initialize plugin
|
// Initialize plugin
|
||||||
load_plugin_textdomain('cannaiq-menus', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
load_plugin_textdomain('cannaiq-menus', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
||||||
|
|
||||||
// Register shortcodes
|
// Register shortcodes - primary CannaIQ shortcodes
|
||||||
add_shortcode('cannaiq_products', [$this, 'products_shortcode']);
|
add_shortcode('cannaiq_products', [$this, 'products_shortcode']);
|
||||||
add_shortcode('cannaiq_product', [$this, 'single_product_shortcode']);
|
add_shortcode('cannaiq_product', [$this, 'single_product_shortcode']);
|
||||||
// Legacy shortcode support (backward compatibility)
|
|
||||||
add_shortcode('crawlsy_products', [$this, 'products_shortcode']);
|
// DEPRECATED: Legacy shortcode aliases for backward compatibility only
|
||||||
add_shortcode('crawlsy_product', [$this, 'single_product_shortcode']);
|
// These allow sites that used the old plugin names to continue working
|
||||||
add_shortcode('dutchie_products', [$this, 'products_shortcode']);
|
// New implementations should use [cannaiq_products] and [cannaiq_product]
|
||||||
add_shortcode('dutchie_product', [$this, 'single_product_shortcode']);
|
add_shortcode('crawlsy_products', [$this, 'products_shortcode']); // deprecated
|
||||||
|
add_shortcode('crawlsy_product', [$this, 'single_product_shortcode']); // deprecated
|
||||||
|
add_shortcode('dutchie_products', [$this, 'products_shortcode']); // deprecated
|
||||||
|
add_shortcode('dutchie_product', [$this, 'single_product_shortcode']); // deprecated
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,9 +65,15 @@ class CannaIQ_Menus_Plugin {
|
|||||||
public function register_elementor_widgets($widgets_manager) {
|
public function register_elementor_widgets($widgets_manager) {
|
||||||
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/product-grid.php';
|
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/product-grid.php';
|
||||||
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/single-product.php';
|
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/single-product.php';
|
||||||
|
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/brand-grid.php';
|
||||||
|
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/category-list.php';
|
||||||
|
require_once CANNAIQ_MENUS_PLUGIN_DIR . 'widgets/specials-grid.php';
|
||||||
|
|
||||||
$widgets_manager->register(new \CannaIQ_Menus_Product_Grid_Widget());
|
$widgets_manager->register(new \CannaIQ_Menus_Product_Grid_Widget());
|
||||||
$widgets_manager->register(new \CannaIQ_Menus_Single_Product_Widget());
|
$widgets_manager->register(new \CannaIQ_Menus_Single_Product_Widget());
|
||||||
|
$widgets_manager->register(new \CannaIQ_Menus_Brand_Grid_Widget());
|
||||||
|
$widgets_manager->register(new \CannaIQ_Menus_Category_List_Widget());
|
||||||
|
$widgets_manager->register(new \CannaIQ_Menus_Specials_Grid_Widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +117,9 @@ class CannaIQ_Menus_Plugin {
|
|||||||
public function register_settings() {
|
public function register_settings() {
|
||||||
register_setting('cannaiq_menus_settings', 'cannaiq_api_token');
|
register_setting('cannaiq_menus_settings', 'cannaiq_api_token');
|
||||||
|
|
||||||
// Migrate old settings if they exist
|
// MIGRATION: Auto-migrate API tokens from old plugin versions
|
||||||
|
// This runs once - if user had crawlsy or dutchie plugin, their token is preserved
|
||||||
|
// Can be removed in a future major version once all users have migrated
|
||||||
$old_crawlsy_token = get_option('crawlsy_api_token');
|
$old_crawlsy_token = get_option('crawlsy_api_token');
|
||||||
$old_dutchie_token = get_option('dutchie_api_token');
|
$old_dutchie_token = get_option('dutchie_api_token');
|
||||||
|
|
||||||
@@ -392,6 +403,152 @@ class CannaIQ_Menus_Plugin {
|
|||||||
|
|
||||||
return $data['product'] ?? false;
|
return $data['product'] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Categories from API
|
||||||
|
*/
|
||||||
|
public function fetch_categories($args = []) {
|
||||||
|
$api_token = get_option('cannaiq_api_token');
|
||||||
|
|
||||||
|
if (!$api_token) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_args = http_build_query($args);
|
||||||
|
$url = CANNAIQ_MENUS_API_URL . '/categories' . ($query_args ? '?' . $query_args : '');
|
||||||
|
|
||||||
|
$response = wp_remote_get($url, [
|
||||||
|
'headers' => [
|
||||||
|
'X-API-Key' => $api_token
|
||||||
|
],
|
||||||
|
'timeout' => 30
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
|
return $data['categories'] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Brands from API
|
||||||
|
*/
|
||||||
|
public function fetch_brands($args = []) {
|
||||||
|
$api_token = get_option('cannaiq_api_token');
|
||||||
|
|
||||||
|
if (!$api_token) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_args = http_build_query($args);
|
||||||
|
$url = CANNAIQ_MENUS_API_URL . '/brands' . ($query_args ? '?' . $query_args : '');
|
||||||
|
|
||||||
|
$response = wp_remote_get($url, [
|
||||||
|
'headers' => [
|
||||||
|
'X-API-Key' => $api_token
|
||||||
|
],
|
||||||
|
'timeout' => 30
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
|
return $data['brands'] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Specials/Deals from API
|
||||||
|
*/
|
||||||
|
public function fetch_specials($args = []) {
|
||||||
|
$api_token = get_option('cannaiq_api_token');
|
||||||
|
|
||||||
|
if (!$api_token) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_args = http_build_query($args);
|
||||||
|
$url = CANNAIQ_MENUS_API_URL . '/specials' . ($query_args ? '?' . $query_args : '');
|
||||||
|
|
||||||
|
$response = wp_remote_get($url, [
|
||||||
|
'headers' => [
|
||||||
|
'X-API-Key' => $api_token
|
||||||
|
],
|
||||||
|
'timeout' => 30
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
|
return $data['products'] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get categories as options for Elementor select control
|
||||||
|
* Returns cached results for performance
|
||||||
|
*/
|
||||||
|
public function get_category_options() {
|
||||||
|
$cache_key = 'cannaiq_category_options';
|
||||||
|
$cached = get_transient($cache_key);
|
||||||
|
|
||||||
|
if ($cached !== false) {
|
||||||
|
return $cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = $this->fetch_categories();
|
||||||
|
$options = ['' => __('All Categories', 'cannaiq-menus')];
|
||||||
|
|
||||||
|
if ($categories) {
|
||||||
|
foreach ($categories as $cat) {
|
||||||
|
$name = $cat['type'] ?? $cat['name'] ?? '';
|
||||||
|
if ($name) {
|
||||||
|
$options[$name] = ucwords(str_replace('_', ' ', $name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_transient($cache_key, $options, 5 * MINUTE_IN_SECONDS);
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get brands as options for Elementor select control
|
||||||
|
* Returns cached results for performance
|
||||||
|
*/
|
||||||
|
public function get_brand_options() {
|
||||||
|
$cache_key = 'cannaiq_brand_options';
|
||||||
|
$cached = get_transient($cache_key);
|
||||||
|
|
||||||
|
if ($cached !== false) {
|
||||||
|
return $cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
$brands = $this->fetch_brands(['limit' => 200]);
|
||||||
|
$options = ['' => __('All Brands', 'cannaiq-menus')];
|
||||||
|
|
||||||
|
if ($brands) {
|
||||||
|
foreach ($brands as $brand) {
|
||||||
|
$name = $brand['brand'] ?? $brand['brand_name'] ?? '';
|
||||||
|
if ($name) {
|
||||||
|
$options[$name] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_transient($cache_key, $options, 5 * MINUTE_IN_SECONDS);
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Plugin
|
// Initialize Plugin
|
||||||
|
|||||||
184
wordpress-plugin/widgets/brand-grid.php
Normal file
184
wordpress-plugin/widgets/brand-grid.php
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Elementor Brand Grid Widget
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CannaIQ_Menus_Brand_Grid_Widget extends \Elementor\Widget_Base {
|
||||||
|
|
||||||
|
public function get_name() {
|
||||||
|
return 'cannaiq_brand_grid';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_title() {
|
||||||
|
return __('CannaIQ Brand Grid', 'cannaiq-menus');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_icon() {
|
||||||
|
return 'eicon-gallery-grid';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_categories() {
|
||||||
|
return ['general'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function register_controls() {
|
||||||
|
|
||||||
|
// Content Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'content_section',
|
||||||
|
[
|
||||||
|
'label' => __('Content', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'limit',
|
||||||
|
[
|
||||||
|
'label' => __('Number of Brands', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||||
|
'default' => 12,
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 100,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'columns',
|
||||||
|
[
|
||||||
|
'label' => __('Columns', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => '4',
|
||||||
|
'options' => [
|
||||||
|
'2' => __('2 Columns', 'cannaiq-menus'),
|
||||||
|
'3' => __('3 Columns', 'cannaiq-menus'),
|
||||||
|
'4' => __('4 Columns', 'cannaiq-menus'),
|
||||||
|
'6' => __('6 Columns', 'cannaiq-menus'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_product_count',
|
||||||
|
[
|
||||||
|
'label' => __('Show Product Count', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'yes',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'link_to_products',
|
||||||
|
[
|
||||||
|
'label' => __('Link to Products Page', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::URL,
|
||||||
|
'placeholder' => __('/products', 'cannaiq-menus'),
|
||||||
|
'description' => __('Brand name will be appended as ?brand=Name', 'cannaiq-menus'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
|
||||||
|
// Style Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'style_section',
|
||||||
|
[
|
||||||
|
'label' => __('Style', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_background',
|
||||||
|
[
|
||||||
|
'label' => __('Card Background', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#ffffff',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-brand-card' => 'background-color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_border_radius',
|
||||||
|
[
|
||||||
|
'label' => __('Border Radius', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||||
|
'size_units' => ['px'],
|
||||||
|
'range' => [
|
||||||
|
'px' => [
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 50,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'default' => [
|
||||||
|
'size' => 8,
|
||||||
|
],
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-brand-card' => 'border-radius: {{SIZE}}{{UNIT}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'text_color',
|
||||||
|
[
|
||||||
|
'label' => __('Text Color', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#333333',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-brand-card' => 'color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function render() {
|
||||||
|
$settings = $this->get_settings_for_display();
|
||||||
|
|
||||||
|
$plugin = CannaIQ_Menus_Plugin::instance();
|
||||||
|
$brands = $plugin->fetch_brands(['limit' => $settings['limit']]);
|
||||||
|
|
||||||
|
if (!$brands) {
|
||||||
|
echo '<p>' . __('No brands found.', 'cannaiq-menus') . '</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = $settings['columns'];
|
||||||
|
$link_base = $settings['link_to_products']['url'] ?? '';
|
||||||
|
?>
|
||||||
|
<div class="cannaiq-brand-grid cannaiq-grid-cols-<?php echo esc_attr($columns); ?>">
|
||||||
|
<?php foreach ($brands as $brand):
|
||||||
|
$brand_name = $brand['brand'] ?? $brand['brand_name'] ?? '';
|
||||||
|
$product_count = $brand['product_count'] ?? 0;
|
||||||
|
$brand_url = $link_base ? $link_base . '?brand=' . urlencode($brand_name) : '#';
|
||||||
|
?>
|
||||||
|
<div class="cannaiq-brand-card"
|
||||||
|
<?php if ($brand_url !== '#'): ?>onclick="window.location.href='<?php echo esc_url($brand_url); ?>'"<?php endif; ?>
|
||||||
|
style="cursor: <?php echo ($brand_url !== '#') ? 'pointer' : 'default'; ?>;">
|
||||||
|
<div class="cannaiq-brand-content">
|
||||||
|
<h3 class="cannaiq-brand-name">
|
||||||
|
<?php echo esc_html($brand_name); ?>
|
||||||
|
</h3>
|
||||||
|
<?php if ($settings['show_product_count'] === 'yes' && $product_count > 0): ?>
|
||||||
|
<span class="cannaiq-brand-count">
|
||||||
|
<?php echo esc_html($product_count); ?> <?php _e('products', 'cannaiq-menus'); ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
205
wordpress-plugin/widgets/category-list.php
Normal file
205
wordpress-plugin/widgets/category-list.php
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Elementor Category List Widget
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CannaIQ_Menus_Category_List_Widget extends \Elementor\Widget_Base {
|
||||||
|
|
||||||
|
public function get_name() {
|
||||||
|
return 'cannaiq_category_list';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_title() {
|
||||||
|
return __('CannaIQ Category List', 'cannaiq-menus');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_icon() {
|
||||||
|
return 'eicon-bullet-list';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_categories() {
|
||||||
|
return ['general'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function register_controls() {
|
||||||
|
|
||||||
|
// Content Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'content_section',
|
||||||
|
[
|
||||||
|
'label' => __('Content', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'layout',
|
||||||
|
[
|
||||||
|
'label' => __('Layout', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => 'grid',
|
||||||
|
'options' => [
|
||||||
|
'grid' => __('Grid', 'cannaiq-menus'),
|
||||||
|
'list' => __('List', 'cannaiq-menus'),
|
||||||
|
'pills' => __('Pills/Tags', 'cannaiq-menus'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'columns',
|
||||||
|
[
|
||||||
|
'label' => __('Columns', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => '3',
|
||||||
|
'options' => [
|
||||||
|
'2' => __('2 Columns', 'cannaiq-menus'),
|
||||||
|
'3' => __('3 Columns', 'cannaiq-menus'),
|
||||||
|
'4' => __('4 Columns', 'cannaiq-menus'),
|
||||||
|
'6' => __('6 Columns', 'cannaiq-menus'),
|
||||||
|
],
|
||||||
|
'condition' => [
|
||||||
|
'layout' => 'grid',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_product_count',
|
||||||
|
[
|
||||||
|
'label' => __('Show Product Count', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'yes',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'link_to_products',
|
||||||
|
[
|
||||||
|
'label' => __('Link to Products Page', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::URL,
|
||||||
|
'placeholder' => __('/products', 'cannaiq-menus'),
|
||||||
|
'description' => __('Category name will be appended as ?category=Name', 'cannaiq-menus'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
|
||||||
|
// Style Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'style_section',
|
||||||
|
[
|
||||||
|
'label' => __('Style', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_background',
|
||||||
|
[
|
||||||
|
'label' => __('Card Background', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#ffffff',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-category-item' => 'background-color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_border_radius',
|
||||||
|
[
|
||||||
|
'label' => __('Border Radius', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||||
|
'size_units' => ['px'],
|
||||||
|
'range' => [
|
||||||
|
'px' => [
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 50,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'default' => [
|
||||||
|
'size' => 8,
|
||||||
|
],
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-category-item' => 'border-radius: {{SIZE}}{{UNIT}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'text_color',
|
||||||
|
[
|
||||||
|
'label' => __('Text Color', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#333333',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-category-item' => 'color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'hover_background',
|
||||||
|
[
|
||||||
|
'label' => __('Hover Background', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#f3f4f6',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-category-item:hover' => 'background-color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function render() {
|
||||||
|
$settings = $this->get_settings_for_display();
|
||||||
|
|
||||||
|
$plugin = CannaIQ_Menus_Plugin::instance();
|
||||||
|
$categories = $plugin->fetch_categories();
|
||||||
|
|
||||||
|
if (!$categories) {
|
||||||
|
echo '<p>' . __('No categories found.', 'cannaiq-menus') . '</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$layout = $settings['layout'];
|
||||||
|
$columns = $settings['columns'];
|
||||||
|
$link_base = $settings['link_to_products']['url'] ?? '';
|
||||||
|
|
||||||
|
$container_class = 'cannaiq-category-' . $layout;
|
||||||
|
if ($layout === 'grid') {
|
||||||
|
$container_class .= ' cannaiq-grid-cols-' . $columns;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="<?php echo esc_attr($container_class); ?>">
|
||||||
|
<?php foreach ($categories as $category):
|
||||||
|
$cat_name = $category['type'] ?? $category['name'] ?? '';
|
||||||
|
$display_name = ucwords(str_replace('_', ' ', $cat_name));
|
||||||
|
$product_count = $category['product_count'] ?? 0;
|
||||||
|
$cat_url = $link_base ? $link_base . '?category=' . urlencode($cat_name) : '#';
|
||||||
|
?>
|
||||||
|
<a href="<?php echo esc_url($cat_url); ?>" class="cannaiq-category-item cannaiq-category-<?php echo esc_attr($layout); ?>-item">
|
||||||
|
<span class="cannaiq-category-name">
|
||||||
|
<?php echo esc_html($display_name); ?>
|
||||||
|
</span>
|
||||||
|
<?php if ($settings['show_product_count'] === 'yes' && $product_count > 0): ?>
|
||||||
|
<span class="cannaiq-category-count">
|
||||||
|
(<?php echo esc_html($product_count); ?>)
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,12 +47,37 @@ class CannaIQ_Menus_Product_Grid_Widget extends \Elementor\Widget_Base {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->add_control(
|
$this->add_control(
|
||||||
'category_id',
|
'category',
|
||||||
[
|
[
|
||||||
'label' => __('Category ID', 'cannaiq-menus'),
|
'label' => __('Category', 'cannaiq-menus'),
|
||||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'description' => __('Leave empty to show all categories', 'cannaiq-menus'),
|
'options' => CannaIQ_Menus_Plugin::instance()->get_category_options(),
|
||||||
|
'description' => __('Filter by product category', 'cannaiq-menus'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'brand',
|
||||||
|
[
|
||||||
|
'label' => __('Brand', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => '',
|
||||||
|
'options' => CannaIQ_Menus_Plugin::instance()->get_brand_options(),
|
||||||
|
'description' => __('Filter by brand', 'cannaiq-menus'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'on_special',
|
||||||
|
[
|
||||||
|
'label' => __('On Special Only', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'no',
|
||||||
|
'description' => __('Show only products on sale', 'cannaiq-menus'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -243,8 +268,16 @@ class CannaIQ_Menus_Product_Grid_Widget extends \Elementor\Widget_Base {
|
|||||||
'in_stock' => $settings['in_stock_only'] === 'yes' ? 'true' : 'false',
|
'in_stock' => $settings['in_stock_only'] === 'yes' ? 'true' : 'false',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($settings['category_id'])) {
|
if (!empty($settings['category'])) {
|
||||||
$args['category_id'] = $settings['category_id'];
|
$args['type'] = $settings['category'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($settings['brand'])) {
|
||||||
|
$args['brandName'] = $settings['brand'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($settings['on_special'] === 'yes') {
|
||||||
|
$args['on_special'] = 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($settings['search'])) {
|
if (!empty($settings['search'])) {
|
||||||
|
|||||||
288
wordpress-plugin/widgets/specials-grid.php
Normal file
288
wordpress-plugin/widgets/specials-grid.php
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Elementor Specials/Deals Grid Widget
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CannaIQ_Menus_Specials_Grid_Widget extends \Elementor\Widget_Base {
|
||||||
|
|
||||||
|
public function get_name() {
|
||||||
|
return 'cannaiq_specials_grid';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_title() {
|
||||||
|
return __('CannaIQ Specials/Deals', 'cannaiq-menus');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_icon() {
|
||||||
|
return 'eicon-price-table';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_categories() {
|
||||||
|
return ['general'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function register_controls() {
|
||||||
|
|
||||||
|
// Content Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'content_section',
|
||||||
|
[
|
||||||
|
'label' => __('Content', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'store_id',
|
||||||
|
[
|
||||||
|
'label' => __('Store ID', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||||
|
'default' => get_option('cannaiq_default_store_id', 1),
|
||||||
|
'min' => 1,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'limit',
|
||||||
|
[
|
||||||
|
'label' => __('Number of Products', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||||
|
'default' => 8,
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 50,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'columns',
|
||||||
|
[
|
||||||
|
'label' => __('Columns', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => '4',
|
||||||
|
'options' => [
|
||||||
|
'2' => __('2 Columns', 'cannaiq-menus'),
|
||||||
|
'3' => __('3 Columns', 'cannaiq-menus'),
|
||||||
|
'4' => __('4 Columns', 'cannaiq-menus'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'category',
|
||||||
|
[
|
||||||
|
'label' => __('Category', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SELECT,
|
||||||
|
'default' => '',
|
||||||
|
'options' => CannaIQ_Menus_Plugin::instance()->get_category_options(),
|
||||||
|
'description' => __('Filter specials by category', 'cannaiq-menus'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
|
||||||
|
// Display Options Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'display_section',
|
||||||
|
[
|
||||||
|
'label' => __('Display Options', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_image',
|
||||||
|
[
|
||||||
|
'label' => __('Show Image', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'yes',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_discount_badge',
|
||||||
|
[
|
||||||
|
'label' => __('Show Discount Badge', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'yes',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_original_price',
|
||||||
|
[
|
||||||
|
'label' => __('Show Original Price', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'yes',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'show_thc',
|
||||||
|
[
|
||||||
|
'label' => __('Show THC', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||||
|
'label_on' => __('Yes', 'cannaiq-menus'),
|
||||||
|
'label_off' => __('No', 'cannaiq-menus'),
|
||||||
|
'return_value' => 'yes',
|
||||||
|
'default' => 'no',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
|
||||||
|
// Style Section
|
||||||
|
$this->start_controls_section(
|
||||||
|
'style_section',
|
||||||
|
[
|
||||||
|
'label' => __('Style', 'cannaiq-menus'),
|
||||||
|
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_background',
|
||||||
|
[
|
||||||
|
'label' => __('Card Background', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#ffffff',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-special-card' => 'background-color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'badge_background',
|
||||||
|
[
|
||||||
|
'label' => __('Badge Background', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#ef4444',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-discount-badge' => 'background-color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'sale_price_color',
|
||||||
|
[
|
||||||
|
'label' => __('Sale Price Color', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::COLOR,
|
||||||
|
'default' => '#16a34a',
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-price-sale' => 'color: {{VALUE}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->add_control(
|
||||||
|
'card_border_radius',
|
||||||
|
[
|
||||||
|
'label' => __('Border Radius', 'cannaiq-menus'),
|
||||||
|
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||||
|
'size_units' => ['px'],
|
||||||
|
'range' => [
|
||||||
|
'px' => [
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 50,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'default' => [
|
||||||
|
'size' => 8,
|
||||||
|
],
|
||||||
|
'selectors' => [
|
||||||
|
'{{WRAPPER}} .cannaiq-special-card' => 'border-radius: {{SIZE}}{{UNIT}};',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->end_controls_section();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function render() {
|
||||||
|
$settings = $this->get_settings_for_display();
|
||||||
|
|
||||||
|
$args = [
|
||||||
|
'store_id' => $settings['store_id'],
|
||||||
|
'limit' => $settings['limit'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($settings['category'])) {
|
||||||
|
$args['type'] = $settings['category'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$plugin = CannaIQ_Menus_Plugin::instance();
|
||||||
|
$products = $plugin->fetch_specials($args);
|
||||||
|
|
||||||
|
if (!$products) {
|
||||||
|
echo '<p>' . __('No specials found.', 'cannaiq-menus') . '</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = $settings['columns'];
|
||||||
|
?>
|
||||||
|
<div class="cannaiq-specials-grid cannaiq-grid-cols-<?php echo esc_attr($columns); ?>">
|
||||||
|
<?php foreach ($products as $product):
|
||||||
|
$image_url = $product['image_url'] ?? $product['primary_image_url'] ?? '';
|
||||||
|
$product_url = !empty($product['menu_url']) ? $product['menu_url'] : '#';
|
||||||
|
$regular_price = $product['regular_price'] ?? 0;
|
||||||
|
$sale_price = $product['sale_price'] ?? $regular_price;
|
||||||
|
$discount = ($regular_price > 0 && $sale_price < $regular_price)
|
||||||
|
? round((($regular_price - $sale_price) / $regular_price) * 100)
|
||||||
|
: 0;
|
||||||
|
?>
|
||||||
|
<div class="cannaiq-special-card"
|
||||||
|
<?php if ($product_url !== '#'): ?>onclick="window.open('<?php echo esc_url($product_url); ?>', '_blank')"<?php endif; ?>
|
||||||
|
style="cursor: <?php echo ($product_url !== '#') ? 'pointer' : 'default'; ?>;">
|
||||||
|
|
||||||
|
<?php if ($settings['show_discount_badge'] === 'yes' && $discount > 0): ?>
|
||||||
|
<div class="cannaiq-discount-badge">
|
||||||
|
-<?php echo esc_html($discount); ?>%
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($settings['show_image'] === 'yes' && !empty($image_url)): ?>
|
||||||
|
<div class="cannaiq-special-image">
|
||||||
|
<img src="<?php echo esc_url($image_url); ?>"
|
||||||
|
alt="<?php echo esc_attr($product['name']); ?>"
|
||||||
|
loading="lazy" />
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="cannaiq-special-content">
|
||||||
|
<h3 class="cannaiq-special-title">
|
||||||
|
<?php echo esc_html($product['name']); ?>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<?php if ($settings['show_thc'] === 'yes' && !empty($product['thc_percentage'])): ?>
|
||||||
|
<span class="cannaiq-meta-item cannaiq-thc">
|
||||||
|
THC: <?php echo esc_html($product['thc_percentage']); ?>%
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="cannaiq-special-price">
|
||||||
|
<span class="cannaiq-price-sale">$<?php echo esc_html($sale_price); ?></span>
|
||||||
|
<?php if ($settings['show_original_price'] === 'yes' && $regular_price > $sale_price): ?>
|
||||||
|
<span class="cannaiq-price-regular cannaiq-strikethrough">$<?php echo esc_html($regular_price); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user