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

MethodParametersDoes
orderorderId 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
productEligibilityproductIdWhether 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

EventFires whenArguments
rating::order.fetched / rating::order.not.fetchedorderresponse or error, order id
rating::store.rated / rating::store.failedstoreresponse or error, payload
rating::products.rated / rating::products.failedproductsresponse or error, payload
rating::shipping.rated / rating::shipping.failedshippingresponse 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 order with "There is no "order_id"!".

See also

On this page