# Shopify Cron Converted Project

This package removes the old MVC/router flow and keeps a cron-only structure.

## Structure

```text
includes/
Labels/
DHL/
config.php
cron_mark_shopify_refunds_in_orders_dbcore.php
cron_get_orders_from_shopify.php
cron_get_locations_from_shopify.php
```

## Core style

All cron files use the same legacy-style core:

- `config.php`
- `includes/global.php`
- `$db->query($sql)`
- `$db->fetch_array($result)`
- Shopify token from `SHOPIFY_CLIENT_ID` / `SHOPIFY_CLIENT_SECRET`
- no `.env`
- no MVC
- no `src/`
- no `public/index.php`

## Main cron jobs

### Get Shopify orders

```text
/cron_get_orders_from_shopify.php?secret=102030&limit=100
```

Optional:

```text
/cron_get_orders_from_shopify.php?secret=102030&shopify_order_id=6860433195258
/cron_get_orders_from_shopify.php?secret=102030&limit=100&fetch_products=1&fetch_refunds=1
```

This syncs:

- `orders`
- `orders_info`
- `order_payments`
- `payment_methods`
- `payment_method_mappings`
- `products`
- `product_variant_mappings`
- `sku_mappings`
- refund JSON/status columns on `orders`

### Get Shopify locations

```text
/cron_get_locations_from_shopify.php?secret=102030
```

This syncs:

- `shopify_locations`
- `shopify_location_mappings`

### Mark local refunded orders

```text
/cron_mark_shopify_refunds_in_orders_dbcore.php?secret=102030&limit=100
```

This checks Shopify refunds and updates local `orders` refund columns only.

## Required config constants

The included `config.php` should define:

```php
SHOPIFY_STORE_DOMAIN
SHOPIFY_CLIENT_ID
SHOPIFY_CLIENT_SECRET
SHOPIFY_API_VERSION
SHOPIFY_TOKEN_CACHE_FILE
NS_INVENTORY_SYNC_SECRET
```

Database credentials are in:

```text
includes/config.php
```
