blob: 3c0a51db22944a116805d2cb2a19b51887c3c8fc [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="createUpdateCustomerAndShippingAddress" short-description="Create/Update Customer, Shipping Address and other contact details." login-required="false">
<call-map-processor xml-resource="component://order/minilang/customer/CheckoutMapProcs.xml"
processor-name="shipToPhone" in-map-name="parameters" out-map-name="shipToPhoneCtx"/>
<call-map-processor xml-resource="component://party/minilang/contact/PartyContactMechMapProcs.xml"
processor-name="emailAddress" in-map-name="parameters" out-map-name="emailAddressCtx"/>
<check-errors/>
<set field="shoppingCart" from-field="parameters.shoppingCart"/>
<set field="partyId" from-field="parameters.partyId"/>
<call-object-method obj-field="shoppingCart" method-name="getUserLogin" ret-field="userLogin"/>
<!-- If registered user is coming then take partyId from userLogin -->
<if-compare field="userLogin != null @and userLogin.partyId != null @and partyId == null" operator="equals" value="true" type="Boolean">
<set field="partyId" from-field="userLogin.partyId"/>
</if-compare>
<set-service-fields service-name="createUpdatePerson" map="parameters" to-map="createUpdatePersonCtx"/>
<set field="createUpdatePersonCtx.userLogin" from-field="userLogin"/>
<set field="createUpdatePersonCtx.partyId" from-field="partyId"/>
<call-service service-name="createUpdatePerson" in-map-name="createUpdatePersonCtx">
<result-to-field result-name="partyId"/>
</call-service>
<if-not-empty field="userLogin">
<if-compare field="userLogin.userLoginId" operator="equals" value="anonymous">
<set field="userLogin.partyId" from-field="partyId"/>
</if-compare>
</if-not-empty>
<set field="partyRoleCtx.partyId" from-field="partyId"/>
<set field="partyRoleCtx.roleTypeId" value="CUSTOMER"/>
<set field="partyRoleCtx.userLogin" from-field="userLogin"/>
<call-service service-name="ensurePartyRole" in-map-name="partyRoleCtx"/>
<!-- Create Update Shipping address -->
<set-service-fields service-name="createUpdateShippingAddress" map="parameters" to-map="shipToAddressCtx"/>
<set field="shipToAddressCtx.userLogin" from-field="userLogin"/>
<call-service service-name="createUpdateShippingAddress" in-map-name="shipToAddressCtx">
<result-to-field result-name="contactMechId" field="parameters.shipToContactMechId"/>
<result-to-result result-name="contactMechId"/>
</call-service>
<!-- Create Update Shipping Telecom Number -->
<set-service-fields service-name="createUpdatePartyTelecomNumber" map="shipToPhoneCtx" to-map="createUpdatePartyTelecomNumberCtx"/>
<set field="createUpdatePartyTelecomNumberCtx.userLogin" from-field="userLogin"/>
<set field="createUpdatePartyTelecomNumberCtx.partyId" from-field="partyId"/>
<set field="createUpdatePartyTelecomNumberCtx.roleTypeId" value="CUSTOMER"/>
<set field="createUpdatePartyTelecomNumberCtx.contactMechPurposeTypeId" value="PHONE_SHIPPING"/>
<set field="createUpdatePartyTelecomNumberCtx.contactMechId" from-field="parameters.shipToPhoneContactMechId" />
<call-service service-name="createUpdatePartyTelecomNumber" in-map-name="createUpdatePartyTelecomNumberCtx">
<result-to-field result-name="contactMechId" field="shipToPhoneContactMechId"/>
<result-to-result result-name="contactMechId" service-result-name="shipToPhoneContactMechId"/>
</call-service>
<if-not-empty field="shipToPhoneContactMechId">
<call-object-method obj-field="shoppingCart" method-name="addContactMech">
<string value="PHONE_SHIPPING"/>
<field field="shipToPhoneContactMechId"/>
</call-object-method>
</if-not-empty>
<!-- Create Update email address -->
<set-service-fields service-name="createUpdatePartyEmailAddress" map="emailAddressCtx" to-map="createUpdatePartyEmailCtx"/>
<set field="createUpdatePartyEmailCtx.contactMechPurposeTypeId" value="PRIMARY_EMAIL"/>
<set field="createUpdatePartyEmailCtx.userLogin" from-field="userLogin"/>
<set field="createUpdatePartyEmailCtx.partyId" from-field="partyId"/>
<call-service service-name="createUpdatePartyEmailAddress" in-map-name="createUpdatePartyEmailCtx">
<result-to-field result-name="contactMechId" field="parameters.emailContactMechId"/>
<result-to-result result-name="contactMechId" service-result-name="emailContactMechId"/>
</call-service>
<field-to-result field="partyId"/>
<if-not-empty field="parameters.emailContactMechId">
<call-object-method obj-field="shoppingCart" method-name="addContactMech">
<string value="ORDER_EMAIL"/>
<field field="parameters.emailContactMechId"/>
</call-object-method>
</if-not-empty>
<call-object-method obj-field="shoppingCart" method-name="setUserLogin">
<field field="userLogin" type="org.apache.ofbiz.entity.GenericValue"/>
<field field="dispatcher" type="org.apache.ofbiz.service.LocalDispatcher"/>
</call-object-method>
<call-object-method obj-field="shoppingCart" method-name="addContactMech">
<string value="SHIPPING_LOCATION"/>
<field field="parameters.shipToContactMechId"/>
</call-object-method>
<call-object-method obj-field="shoppingCart" method-name="setAllShippingContactMechId">
<field field="parameters.shipToContactMechId"/>
</call-object-method>
<call-object-method obj-field="shoppingCart" method-name="setOrderPartyId">
<field field="partyId"/>
</call-object-method>
</simple-method>
<simple-method method-name="createUpdateBillingAddressAndPaymentMethod" short-description="Create/update billing address and payment information" login-required="false">
<call-map-processor xml-resource="component://order/minilang/customer/CheckoutMapProcs.xml"
processor-name="billToPhone" in-map-name="parameters" out-map-name="billToPhoneContext"/>
<check-errors/>
<set field="shoppingCart" from-field="parameters.shoppingCart"/>
<call-object-method obj-field="shoppingCart" method-name="getUserLogin" ret-field="userLogin"/>
<set field="partyId" from-field="parameters.partyId"/>
<!-- If registered user is coming then take partyId from userLogin -->
<if-compare field="userLogin != null @and partyId == null" operator="equals" value="true" type="Boolean">
<set field="partyId" from-field="userLogin.partyId"/>
</if-compare>
<set field="shipToContactMechId" from-field="parameters.shipToContactMechId"/>
<if-not-empty field="shoppingCart">
<if-empty field="partyId">
<call-object-method obj-field="shoppingCart" method-name="getPartyId" ret-field="partyId"/>
</if-empty>
<if-empty field="shipToContactMechId">
<call-object-method obj-field="shoppingCart" method-name="getShippingContactMechId" ret-field="shipToContactMechId"/>
</if-empty>
</if-not-empty>
<if-not-empty field="partyId">
<if-compare field="userLogin.userLoginId" operator="equals" value="anonymous">
<set field="userLogin.partyId" from-field="partyId"/>
</if-compare>
</if-not-empty>
<!-- Create Update Billing address -->
<set-service-fields service-name="createUpdateBillingAddress" map="parameters" to-map="billToAddressCtx"/>
<set field="billToAddressCtx.userLogin" from-field="userLogin"/>
<call-service service-name="createUpdateBillingAddress" in-map-name="billToAddressCtx">
<result-to-field result-name="contactMechId" field="parameters.billToContactMechId"/>
<result-to-result result-name="contactMechId"/>
</call-service>
<if-not-empty field="parameters.billToContactMechId">
<call-object-method obj-field="shoppingCart" method-name="addContactMech">
<string value="BILLING_LOCATION"/>
<field field="parameters.billToContactMechId"/>
</call-object-method>
</if-not-empty>
<!-- Create Update Billing Telecom Number -->
<set-service-fields service-name="createUpdatePartyTelecomNumber" map="billToPhoneContext" to-map="createUpdatePartyTelecomNumberCtx"/>
<set field="createUpdatePartyTelecomNumberCtx.userLogin" from-field="userLogin"/>
<set field="createUpdatePartyTelecomNumberCtx.partyId" from-field="partyId"/>
<set field="createUpdatePartyTelecomNumberCtx.roleTypeId" value="CUSTOMER"/>
<set field="createUpdatePartyTelecomNumberCtx.contactMechPurposeTypeId" value="PHONE_BILLING"/>
<set field="createUpdatePartyTelecomNumberCtx.contactMechId" from-field="parameters.billToPhoneContactMechId" />
<call-service service-name="createUpdatePartyTelecomNumber" in-map-name="createUpdatePartyTelecomNumberCtx">
<result-to-field result-name="contactMechId" field="billToPhoneContactMechId"/>
<result-to-result result-name="contactMechId" service-result-name="billToPhoneContactMechId"/>
</call-service>
<if-not-empty field="billToPhoneContactMechId">
<call-object-method obj-field="shoppingCart" method-name="addContactMech">
<string value="PHONE_BILLING"/>
<field field="billToPhoneContactMechId"/>
</call-object-method>
</if-not-empty>
<!-- Create Update credit card -->
<set-service-fields service-name="createUpdateCreditCard" map="parameters" to-map="creditCardCtx"/>
<set field="creditCardCtx.contactMechId" from-field="parameters.billToContactMechId"/>
<set field="creditCardCtx.userLogin" from-field="userLogin"/>
<call-service service-name="createUpdateCreditCard" in-map-name="creditCardCtx">
<result-to-field result-name="paymentMethodId"/>
<result-to-result result-name="paymentMethodId"/>
</call-service>
<!-- Set Payment Method-->
<set field="cardSecurityCode" from-field="parameters.billToCardSecurityCode" set-if-null="true" set-if-empty="true"/>
<create-object class-name="org.apache.ofbiz.order.shoppingcart.CheckOutHelper" field="checkOutHelper">
<field field="dispatcher" type="org.apache.ofbiz.service.LocalDispatcher"/>
<field field="delegator" type="org.apache.ofbiz.entity.Delegator"/>
<field field="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart"/>
</create-object>
<set field="callResult" value="${groovy:checkOutHelper.finalizeOrderEntryPayment(paymentMethodId, null, false, false)}"/>
<set field="cartPaymentInfo" value="${groovy: org.apache.ofbiz.order.shoppingcart.ShoppingCart.CartPaymentInfo cpi = shoppingCart.getPaymentInfo(paymentMethodId, null, null, null, true); cpi.securityCode = cardSecurityCode; return cpi;}"/>
<check-errors/>
</simple-method>
<simple-method method-name="setAnonUserLogin" short-description="Set user login in the session" login-required="false">
<set field="shoppingCart" from-field="parameters.shoppingCart"/>
<call-object-method obj-field="shoppingCart" method-name="getUserLogin" ret-field="userLogin"/>
<if-empty field="userLogin">
<entity-one entity-name="UserLogin" value-field="userLogin">
<field-map field-name="userLoginId" value="anonymous"/>
</entity-one>
<else>
<!-- If an anonymous user is coming back, update the party id in the userLogin object -->
<if-compare field="userLogin.userLoginId" operator="equals" value="anonymous">
<set field="userLogin.partyId" from-field="parameters.partyId"/>
</if-compare>
</else>
</if-empty>
<call-object-method obj-field="shoppingCart" method-name="setUserLogin">
<field field="userLogin" type="org.apache.ofbiz.entity.GenericValue"/>
<field field="dispatcher" type="org.apache.ofbiz.service.LocalDispatcher"/>
</call-object-method>
</simple-method>
</simple-methods>