Ejemplos: Habilitación de recargos

Una tarifa de recargo, o tarifa de paso por caja, es una tarifa adicional que cobra un comerciante al recibir un pago.

Estos ejemplos muestran cómo puede habilitar un recargo utilizando la infraestructura de cálculo a nivel de artículo y a nivel de pedido.

Item-level example

Cuando un comprador adquiere un producto (por ejemplo, Código de artículo FUOF-0101), se cobra un cargo adicional de 5 euros por manipulación y envío junto con otros importes monetarios del pedido (total del producto, el envío, los impuestos, etc.). Detalle del producto en la tienda de ejemplo del entorno de desarrollo:

  • Nombre del producto: Sillón tapizado en blanco
  • Código de artículo (número de pieza): FUOF-0101
  • Catentry_id: 10252
  • Tarifa especial de envío/manipulación (recargo): 5,00 euros por artículo

Ejemplo de datos de configuración de recargo para el escenario:

  1. Cree un calcode para representar la 'tarifa de manipulación especial' en el uso de cálculo de recargo. También puede cambiar la descripción.
    INSERT INTO CALCODE (CALCODE_ID,CODE,CALUSAGE_ID,STOREENT_ID,GROUPBY,PUBLISHED,SEQUENCE,CALMETHOD_ID,CALMETHOD_ID_APP,CALMETHOD_ID_QFY,DESCRIPTION,DISPLAYLEVEL,FLAGS,PRECEDENCE) values (66666,'surcharge for special handling calcode',6,-1,0,1,0,707060103,707060104,707060102,'surcharge for special handling calculation code description',0,0,0);
  2. Cree una descripción dependiente del idioma para calcode. Sólo se utiliza para fines de visualización. También puede cambiar la descripción.
    INSERT INTO CALCODEDSC (CALCODE_ID,LANGUAGE_ID,DESCRIPTION,LONGDESCRIPTION) VALUES (66666,-1,'surcharge for special handling calculation code description in description table','longer version of surcharge for special handling calculation code description in the description table');
  3. Conecte el código de cálculo con el producto. Debe añadir una entrada similar a la base de datos para cada producto (catentry_id) con el que desea tener asociado el recargo.
    INSERT INTO CATENCALCD (STORE_ID,CATENCALCD_ID,CATENTRY_ID,CALCODE_ID) VALUES (1,66671,10252,66666);
  4. Cree la norma de cálculo para el código de cálculo. Representa tarifas de cargo.
    INSERT INTO CALRULE (CALRULE_ID,CALCODE_ID,SEQUENCE,COMBINATION,CALMETHOD_ID,CALMETHOD_ID_QFY,FLAGS,IDENTIFIER) VALUES (66667,66666,0,2,707060107,707060106,0,1);
  5. Cree las propiedades de escala de cálculo.
    INSERT INTO CALSCALE (CALSCALE_ID,QTYUNIT_ID,CODE,STOREENT_ID,CALUSAGE_ID,CALMETHOD_ID) VALUES (66668,'C62','scale-surchargeSH',-1,-6,-707060108);
  6. Asocie las propiedades de escala de cálculo con las normas de cálculo.
    INSERT INTO CRULESCALE (CALSCALE_ID,CALRULE_ID) VALUES (66668,66667);
  7. Cree los rangos para los cálculos.
    INSERT INTO CALRANGE (CALRANGE_ID,CALSCALE_ID,CALMETHOD_ID,RANGESTART) VALUES (66669,66668,-707060110,0);
  8. Cree el valor de recargo y asócielo a los cálculos. Puede cambiar el valor del recargo con esta sentencia SQL.
    INSERT INTO CALRLOOKUP (CALRLOOKUP_ID,CALRANGE_ID,VALUE) VALUES (66670,66669,5);
  9. Cambie las JSP del escaparate para visualizar el recargo. El ejemplo de Ajuste de recargo se toma de .../Stores/WebContent/ConsumerDirect/Snippets/Order/Inventory/CurrentAndTotalCharges.jsp
    <tr>
       <td colspan="5" class="
       <c:out value="${rowClass}"/>
       price t_td"
       id="WC_CurrentAndTotalCharges_TableCell_9">
       <fmt:message key="OrderSummary_TOTAL_PRODUCT" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_DISCOUNT" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_SURCHARGE" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_TAX" bundle="${orderText}" />
       <br
          />
       <c:if test="${showBaseShipAndAdjust}" >
          <fmt:message key="OrderSummary_TOTAL_ORIGINAL_SHIPPING"
             bundle="${orderText}" />
          <br />
          <fmt:message key="OrderSummary_TOTAL_SHIPPING_ADJUSTMENT"
             bundle="${orderText}" />
          <br />
       </c:if>
       <c:if test="${showAdjustedShipCharges}">
          <fmt:message key="OrderSummary_TOTAL_SHIPPING" bundle="${orderText}"
             />
          <br />
       </c:if>
       <fmt:message key="OrderSummary_TOTAL_SHIPPINGTAX"
          bundle="${orderText}" />
       </td>
       <td class="
       <c:out value="${rowClass}"/>
       price t_td"
       id="WC_CurrentAndTotalCharges_TableCell_10">
       <c:out value="${order_OrderDataBean.formattedTotalProductPrice}"
          escapeXml="false" />
       <br />
       <c:out value="${order_OrderDataBean.formattedTotalDiscountAdjustment}"
          escapeXml="false" />
       <br />
       <c:out
          value="${order_OrderDataBean.formattedTotalSurchargeAdjustment}"
          escapeXml="false" />
       <br />
       <c:out value="${order_OrderDataBean.formattedTotalTax}"
          escapeXml="false" />
       <br />
       <c:if test="${showBaseShipAndAdjust}" >
          <c:out value="${order_OrderDataBean.formattedShippingCharge}"
             escapeXml="false"/>
          <br />
          <c:out
             value="${order_OrderDataBean.formattedTotalShippingAdjustment}"
             escapeXml="false" />
          <br />
       </c:if>
       <c:if test="${showAdjustedShipCharges}">
          <c:out value="${order_OrderDataBean.formattedTotalShippingCharge}"
             escapeXml="false" />
          <br />
       </c:if>
       <c:out value="${order_OrderDataBean.formattedTotalShippingTax}"
          escapeXml="false" />
       </td>
    </tr>
  10. Puede obtener el valor de recargo de OrderDataBean.getFormattedTotalSurchargeAdjustment().

Ejemplo a nivel de pedido

Cuando un comprador compra una selección de productos, se cobra un recargo adicional de 5 euros por el cargo de servicio de entrega junto con otros importes monetarios del pedido (incluidos el total del producto, el envío, los impuestos, entre otros). Detalle del producto en la tienda de ejemplo del entorno de desarrollo:

  • Tarifa especial de envío/manipulación (recargo): 5,00 euros por pedido

Ejemplo de datos de configuración de recargo para el escenario:

  1. Cree un calcode para representar la 'tarifa de manipulación especial' en el uso de cálculo de recargo. También puede cambiar la descripción.
    INSERT INTO CALCODE (CALCODE_ID,CODE,CALUSAGE_ID,STOREENT_ID,GROUPBY,PUBLISHED,SEQUENCE,CALMETHOD_ID,CALMETHOD_ID_APP,CALMETHOD_ID_QFY,DESCRIPTION,DISPLAYLEVEL,FLAGS,PRECEDENCE) VALUES (66666,'surcharge for delivery service',-6,-1,0,1,0,-707060103,-707060104,-707060102,'surcharge for delivery service description',0,0,0);
  2. Cree una descripción dependiente del idioma para calcode. Sólo se utiliza para fines de visualización. También puede cambiar la descripción.
    INSERT INTO CALCODEDSC (CALCODE_ID,LANGUAGE_ID,DESCRIPTION,LONGDESCRIPTION) VALUES (66666,-1,'surcharge for delivery service description in description table','longer version of surcharge for delivery service description in the description table');
  3. Cree la norma de cálculo para el código de cálculo. Representa tarifas de cargo.
    INSERT INTO CALRULE (CALRULE_ID,CALCODE_ID,SEQUENCE,COMBINATION,CALMETHOD_ID,CALMETHOD_ID_QFY,FLAGS,IDENTIFIER) VALUES (66667,66666,0,2,-707060107,-707060106,0,1);
  4. Cree las propiedades de escala de cálculo.
    INSERT INTO CALSCALE (CALSCALE_ID,QTYUNIT_ID,CODE,STOREENT_ID,CALUSAGE_ID,CALMETHOD_ID) VALUES (66668,'C62','special handling',-1,-6,-707060108);
  5. Asocie las propiedades de escala de cálculo con las normas de cálculo.
    INSERT INTO CRULESCALE (CALSCALE_ID,CALRULE_ID) VALUES (66668,66667);
  6. Cree los rangos para los cálculos.
    INSERT INTO CALRANGE (CALRANGE_ID,CALSCALE_ID,CALMETHOD_ID,RANGESTART) VALUES (66669,66668,-707060110,0);
  7. Cree el valor de recargo y asócielo a los cálculos. Puede cambiar el valor del recargo con esta sentencia SQL.
    INSERT INTO CALRLOOKUP (CALRLOOKUP_ID,CALRANGE_ID,VALUE) VALUES (66670,66669,5);
  8. Aplique el nuevo recargo para utilizarlo en la tienda.
    UPDATE STENCALUSG SET CALCODE_ID=66666 WHERE CALUSAGE_ID=-6;
  9. Cambie las JSP del escaparate para visualizar el recargo. El ejemplo de Ajuste de recargo se toma de .../Stores/WebContent/ConsumerDirect/Snippets/Order/Inventory/CurrentAndTotalCharges.jsp
    <tr>
       <td colspan="5" class="
       <c:out value="${rowClass}"/>
       price t_td"
       id="WC_CurrentAndTotalCharges_TableCell_9">
       <fmt:message key="OrderSummary_TOTAL_PRODUCT" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_DISCOUNT" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_SURCHARGE" bundle="${orderText}"
          />
       <br />
       <fmt:message key="OrderSummary_TOTAL_TAX" bundle="${orderText}" />
       <br
          />
       <c:if test="${showBaseShipAndAdjust}" >
          <fmt:message key="OrderSummary_TOTAL_ORIGINAL_SHIPPING"
             bundle="${orderText}" />
          <br />
          <fmt:message key="OrderSummary_TOTAL_SHIPPING_ADJUSTMENT"
             bundle="${orderText}" />
          <br />
       </c:if>
       <c:if test="${showAdjustedShipCharges}">
          <fmt:message key="OrderSummary_TOTAL_SHIPPING" bundle="${orderText}"
             />
          <br />
       </c:if>
       <fmt:message key="OrderSummary_TOTAL_SHIPPINGTAX"
          bundle="${orderText}" />
       </td>
       <td class="
       <c:out value="${rowClass}"/>
       price t_td"
       id="WC_CurrentAndTotalCharges_TableCell_10">
       <c:out value="${order_OrderDataBean.formattedTotalProductPrice}"
          escapeXml="false" />
       <br />
       <c:out value="${order_OrderDataBean.formattedTotalDiscountAdjustment}"
          escapeXml="false" />
       <br />
       <c:out
          value="${order_OrderDataBean.formattedTotalSurchargeAdjustment}"
          escapeXml="false" />
       <br />
       <c:out value="${order_OrderDataBean.formattedTotalTax}"
          escapeXml="false" />
       <br />
       <c:if test="${showBaseShipAndAdjust}" >
          <c:out value="${order_OrderDataBean.formattedShippingCharge}"
             escapeXml="false"/>
          <br />
          <c:out
             value="${order_OrderDataBean.formattedTotalShippingAdjustment}"
             escapeXml="false" />
          <br />
       </c:if>
       <c:if test="${showAdjustedShipCharges}">
          <c:out value="${order_OrderDataBean.formattedTotalShippingCharge}"
             escapeXml="false" />
          <br />
       </c:if>
       <c:out value="${order_OrderDataBean.formattedTotalShippingTax}"
          escapeXml="false" />
       </td>
    </tr>
  10. Puede obtener el valor de recargo de OrderDataBean.getFormattedTotalSurchargeAdjustment().