rating
Let the customer rate the store, the products and the shipping of an order they received.
Use Salla.rating after an order is delivered, when the customer rates it. The salla-rating-modal web component runs the whole flow, so check it first: see salla-rating-modal.
// what can be rated for this order
const { data } = await Salla.rating.order(978);
await Salla.rating.store({ order_id: 978, rating: 5, comment: 'Fast and friendly' });Methods
| Method | Parameters | Does |
|---|---|---|
order | orderId or { order_id } | Reads what the customer can rate for the order |
store | { order_id, rating, comment? } | Rates the store |
products | { order_id, products: [{ product_id, rating, comment? }] } | Rates the order's products |
shipping | { order_id, shipping_company_id, rating, comment? } | Rates the shipping company |
productEligibility | productId | Whether the customer may rate this product. No events. |
rating is the number of stars.
await Salla.rating.products({
order_id: 589,
products: [
{ product_id: 5871, rating: 5, comment: 'Good quality' },
{ product_id: 2589, rating: 4 },
],
});Events
| Event | Fires when | Arguments |
|---|---|---|
rating::order.fetched / rating::order.not.fetched | order | response or error, order id |
rating::store.rated / rating::store.failed | store | response or error, payload |
rating::products.rated / rating::products.failed | products | response or error, payload |
rating::shipping.rated / rating::shipping.failed | shipping | response or error, payload |
Gotchas
- These calls need a logged-in customer.
- Each method without its payload rejects at once with "There is no "data"!", or for
orderwith "There is no "order_id"!".