Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Service/Product/PriceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ public function execute(array $config, Product $product): array
if ($extraRenderedPriceFields = preg_grep('/^rendered_price__/', array_keys($attributes))) {
foreach ($extraRenderedPriceFields as $label) {
$field = $attributes[$label];
$renderCurrency = $field['actions'][0] ? explode('_', $field['actions'][0])[1] : null;
if ($renderCurrency !== $config['currency']) {
$action = $field['actions'][0] ?? null;
$renderCurrency = ($action && strpos($action, 'currency_') === 0)
? explode('_', $action, 2)[1]
: null;

if ($renderCurrency !== null && $renderCurrency !== $config['currency']) {
$newConfig = $config;
$newConfig['currency'] = $renderCurrency;
$newConfig['exchange_rate'] = $config['exchange_rate_' . $renderCurrency] ?? 1;
Expand All @@ -212,16 +216,18 @@ public function execute(array $config, Product $product): array
$prices[$field['label']] = $this->processPrice($product, $price, $newConfig);
break;
case 'min_price':
$price = $minPrice ?? $price;
$prices[$field['label']] = $this->processPrice($product, $price, $newConfig);
$prices[$field['label']] = $this->processPrice($product, $minPrice ?? $price, $newConfig);
break;
case 'max_price':
$price = $maxPrice ?? $price;
$prices[$field['label']] = $this->processPrice($product, $price, $newConfig);
$prices[$field['label']] = $this->processPrice($product, $maxPrice ?? $price, $newConfig);
break;
}
} else {
$prices[$field['label']] = $prices[$field['price_source']] ?? null;
$value = $prices[$field['price_source']] ?? null;
if ($action === 'round' && $value !== null) {
$value = preg_replace('/[\d.]+/', number_format(round((float)$value), 2, '.', ''), $value, 1);
}
$prices[$field['label']] = $value;
}
}
}
Expand Down
127 changes: 127 additions & 0 deletions docs/RETURNS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Returns

This guide explains how returns work in the [Channable module](https://www.magmodules.eu/magento2-channable.html). It covers the full return flow — from a marketplace customer requesting a return, to the return appearing in your Magento admin, to creating a credit memo. Whether you're processing returns manually or want to automate the whole thing, this page has you covered.

## How Returns Work

When a customer initiates a return on a marketplace (e.g., bol, Amazon), Channable picks it up and pushes it to your Magento store via a webhook. The return lands in the **Channable → Returns** grid in the admin, linked to the original order.

From there you can:
- Review the return details (item, reason, customer)
- Update the status (accept, reject, repair, exchange, etc.)
- Create a credit memo — manually or automatically

The status you set is sent back to Channable, which updates the marketplace accordingly.

## Setting Up Returns

**Location:** Stores → Configuration → Channable → Returns

### Enable

Turns the returns feature on or off per store view.

### Webhooks

After enabling, a webhook URL is generated for each store view. Copy this URL and paste it into your Channable account under the marketplace connection settings. Make sure you copy the full URL — it's long and may be partially hidden.

**Format:** `{base_url}/channable/returns/hook/store/{store_id}/code/{token}`

### Show Return Block on Credit Memo Page

When enabled, a return block appears on the credit memo creation page for Channable orders that have a pending return. This lets you manually select which return(s) to link when creating the credit memo.

### Automatically Match Returns

When enabled, any pending return is automatically marked as "accepted" when you create a credit memo for that order. This overrides the manual return block selection.

**When to use:** You have established processes to handle credit memos and don't need to manually review each return.

### Credit Memo Completed Returns

When enabled, a credit memo is created automatically for returns that arrive with status "complete". These are returns already handled and fulfilled by the marketplace itself — the module just mirrors that in Magento.

## Return Statuses

| Status | Meaning |
|---|---|
| New | Just imported, awaiting action |
| Accepted | Return approved, refund will be processed |
| Rejected | Return declined |
| Repaired | Item will be repaired and sent back |
| Exchanged | Item will be replaced with a new one |
| Keeps | Customer keeps the item (no return shipment) |
| Cancelled | Return process was cancelled |
| Complete | Fully processed on marketplace side |

## Returns Grid

**Location:** Channable → Returns

The grid shows all imported returns with the following information:

**Columns:**
- Store, Magento Order, Credit Memo
- Channel Return ID, Channel Order ID
- Customer Name
- Item (formatted as "Qty x Title (GTIN)")
- Reason (including customer comments)
- Order Credit Memos (count)
- Order Status
- Imported Date
- Status

### Row Actions

When a return has status "new", you can set it to any other status directly from the grid: Accept, Reject, Repair, Exchange, Keep, or Cancel.

### Mass Actions

- **Re-process** — Re-links selected returns to their Magento orders (useful if order wasn't found during initial import)
- **Create Credit Memo** — Creates a credit memo for the linked order
- **Create Credit Memo + Accept** — Creates a credit memo and sets return status to "accepted"
- **Delete** — Removes the return from Magento (does not update Channable)

## Credit Memo Integration

The module can create credit memos from returns in three ways:

### 1. Manual via Mass Action
Select returns in the grid → "Create Credit Memo" mass action. The module finds the order item by matching the GTIN from the return to a product SKU (or configured GTIN attribute).

### 2. Return Block on Credit Memo Page
When "Show Return Block on Credit Memo Page" is enabled, you'll see a block with checkboxes on the credit memo creation page. Select which returns to link, and saving the credit memo updates those returns to "accepted".

### 3. Fully Automatic
Enable both "Automatically Match Returns" and "Credit Memo Completed Returns". Returns arriving as "complete" get a credit memo created automatically. Returns in "new" status get marked "accepted" whenever you create a credit memo for their order.

## GTIN Matching

When creating a credit memo from a return, the module needs to match the returned item to an order line. It does this using the GTIN (barcode) from the return data.

The GTIN attribute is configured under: Stores → Configuration → Channable → Feed → GTIN Attribute

Options:
- **SKU** (default) — matches directly on SKU
- **EAN/barcode attribute** — matches on a custom product attribute
- **Product ID** — uses the numeric product ID

### Product ID Fallback

Some marketplaces don't include a GTIN in their return data. When the configured GTIN attribute doesn't produce a match and the value is numeric, the module automatically tries to load the product by entity ID as a fallback.

If neither the attribute match nor the ID fallback finds a product, the credit memo creation will fail and an error is logged.

## Test Returns

You can create test returns from the admin grid via the "Simulate" button. This creates a return with random product data (or a specific order if configured) without needing an actual Channable webhook call. Useful for testing your configuration before going live.

---

## Need More Help?

**Documentation:**
- [All Help Articles](https://www.magmodules.eu/help/channable/) - Complete documentation overview

**Support:**
- [Contact Support](https://www.magmodules.eu/support/) - Get help from our team
127 changes: 127 additions & 0 deletions docs/RETURNS_NL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Retouren

Deze gids legt uit hoe retouren werken in de [Channable module](https://www.magmodules.eu/nl/magento2-channable.html). Het behandelt de volledige retourstroom — van een klant die een retour aanvraagt op een marktplaats, tot de retour in uw Magento admin, tot het aanmaken van een creditnota. Of u retouren handmatig verwerkt of het hele proces wilt automatiseren, op deze pagina vindt u alle informatie.

## Hoe Retouren Werken

Wanneer een klant een retour aanvraagt op een marktplaats (bijv. bol, Amazon), pikt Channable dit op en stuurt het via een webhook naar uw Magento-webshop. De retour verschijnt in het **Channable → Retouren** overzicht in de admin, gekoppeld aan de originele bestelling.

Van daaruit kunt u:
- De retourgegevens bekijken (artikel, reden, klant)
- De status bijwerken (accepteren, afwijzen, repareren, omruilen, etc.)
- Een creditnota aanmaken — handmatig of automatisch

De status die u instelt wordt teruggestuurd naar Channable, dat vervolgens de marktplaats bijwerkt.

## Retouren Instellen

**Locatie:** Winkels → Configuratie → Channable → Retouren

### Inschakelen

Schakelt de retourfunctie in of uit per storeview.

### Webhooks

Na het inschakelen wordt er een webhook-URL gegenereerd voor elke storeview. Kopieer deze URL en plak deze in uw Channable-account bij de marktplaatskoppeling. Zorg ervoor dat u de volledige URL kopieert — deze is lang en kan gedeeltelijk verborgen zijn.

**Formaat:** `{base_url}/channable/returns/hook/store/{store_id}/code/{token}`

### Retourblok Tonen op Creditnotapagina

Wanneer ingeschakeld verschijnt er een retourblok op de creditnota-aanmaakpagina voor Channable-bestellingen met een openstaande retour. Hiermee kunt u handmatig selecteren welke retour(en) u wilt koppelen bij het aanmaken van de creditnota.

### Retouren Automatisch Koppelen

Wanneer ingeschakeld wordt elke openstaande retour automatisch als "geaccepteerd" gemarkeerd wanneer u een creditnota aanmaakt voor die bestelling. Dit overschrijft de handmatige selectie in het retourblok.

**Wanneer gebruiken:** U heeft vaste processen voor het afhandelen van creditnota's en hoeft niet elke retour handmatig te beoordelen.

### Creditnota voor Afgeronde Retouren

Wanneer ingeschakeld wordt automatisch een creditnota aangemaakt voor retouren die binnenkomen met de status "complete". Dit zijn retouren die al afgehandeld zijn door de marktplaats zelf — de module spiegelt dit alleen in Magento.

## Retourstatussen

| Status | Betekenis |
|---|---|
| New | Zojuist geïmporteerd, wacht op actie |
| Accepted | Retour goedgekeurd, terugbetaling wordt verwerkt |
| Rejected | Retour afgewezen |
| Repaired | Artikel wordt gerepareerd en teruggestuurd |
| Exchanged | Artikel wordt vervangen door een nieuw exemplaar |
| Keeps | Klant behoudt het artikel (geen retourzending) |
| Cancelled | Retourproces is geannuleerd |
| Complete | Volledig afgehandeld aan marktplaatszijde |

## Retourenoverzicht

**Locatie:** Channable → Retouren

Het overzicht toont alle geïmporteerde retouren met de volgende informatie:

**Kolommen:**
- Winkel, Magento Bestelling, Creditnota
- Kanaal Retour-ID, Kanaal Bestelling-ID
- Klantnaam
- Artikel (weergegeven als "Aantal x Titel (GTIN)")
- Reden (inclusief opmerkingen van de klant)
- Bestelling Creditnota's (aantal)
- Bestelstatus
- Importdatum
- Status

### Rijacties

Wanneer een retour de status "new" heeft, kunt u deze direct vanuit het overzicht op een andere status zetten: Accepteren, Afwijzen, Repareren, Omruilen, Behouden of Annuleren.

### Massacties

- **Opnieuw verwerken** — Koppelt geselecteerde retouren opnieuw aan hun Magento-bestellingen (handig als de bestelling niet gevonden werd tijdens de eerste import)
- **Creditnota Aanmaken** — Maakt een creditnota aan voor de gekoppelde bestelling
- **Creditnota Aanmaken + Accepteren** — Maakt een creditnota aan en zet de retourstatus op "accepted"
- **Verwijderen** — Verwijdert de retour uit Magento (wordt niet bijgewerkt in Channable)

## Creditnota-integratie

De module kan op drie manieren creditnota's aanmaken vanuit retouren:

### 1. Handmatig via Massacties
Selecteer retouren in het overzicht → "Creditnota Aanmaken" massactie. De module zoekt het bestelregel op basis van het GTIN uit de retourdata en het product-SKU (of geconfigureerd GTIN-attribuut).

### 2. Retourblok op Creditnotapagina
Wanneer "Retourblok Tonen op Creditnotapagina" is ingeschakeld, ziet u een blok met selectievakjes op de creditnota-aanmaakpagina. Selecteer welke retouren u wilt koppelen, en bij het opslaan van de creditnota worden deze retouren op "accepted" gezet.

### 3. Volledig Automatisch
Schakel zowel "Retouren Automatisch Koppelen" als "Creditnota voor Afgeronde Retouren" in. Retouren die binnenkomen als "complete" krijgen automatisch een creditnota. Retouren met status "new" worden als "accepted" gemarkeerd zodra u een creditnota aanmaakt voor hun bestelling.

## GTIN-koppeling

Bij het aanmaken van een creditnota vanuit een retour moet de module het geretourneerde artikel koppelen aan een bestelregel. Dit gebeurt op basis van het GTIN (barcode) uit de retourdata.

Het GTIN-attribuut wordt geconfigureerd onder: Winkels → Configuratie → Channable → Feed → GTIN Attribuut

Opties:
- **SKU** (standaard) — koppelt direct op SKU
- **EAN/barcode-attribuut** — koppelt op een aangepast productattribuut
- **Product-ID** — gebruikt het numerieke product-ID

### Product-ID Fallback

Sommige marktplaatsen sturen geen GTIN mee in hun retourdata. Wanneer het geconfigureerde GTIN-attribuut geen match oplevert en de waarde numeriek is, probeert de module automatisch het product te laden op basis van het entity-ID.

Als noch de attribuutkoppeling noch de ID-fallback een product vindt, mislukt het aanmaken van de creditnota en wordt er een fout gelogd.

## Testretouren

U kunt testretouren aanmaken vanuit het adminoverzicht via de "Simuleer" knop. Dit maakt een retour aan met willekeurige productdata (of een specifieke bestelling indien geconfigureerd) zonder dat er een echte Channable-webhook nodig is. Handig om uw configuratie te testen voordat u live gaat.

---

## Meer Hulp Nodig?

**Documentatie:**
- [Alle Help Artikelen](https://www.magmodules.eu/nl/help/channable/) - Compleet documentatie overzicht

**Support:**
- [Contact Opnemen](https://www.magmodules.eu/nl/support/) - Hulp van ons team
Loading