how to insert "billing" or "shipment" address based on logged-on user ?
Hi,
How can we insert "billing" or "shipment" address when the address.aspx is accessed using AddressInformation[XSLT].xslt .
can any one explain the logic behind populating the addresses based on logged-on user, making a selection like "billing or shipment" from dropdown as shown in UcommerceDemo store.
If you want to use a stored address you can use CommerceLibrary:EditCustomerAddress to create a new address for the customer currently logged in for later use.
how to pre-populate the address of logged in customer when he access address.aspx page in ucommerce demo store...using above AddressInformation[XSLT]...
I'm having the same problem. I'm using Umbraco 4.9 and UCommerce 2.6.1.0. I complete the order, customer is created and UCommerce_OrderAddress table is populated. Later when placing order with the same customer and using CommerceLibrary:GetBasket() i get empty address element. Also the table UCommerce_Address is empty. Can you explain what i'm doing wrong?
Looks like you need to use the CommerceLibrary:EditCustomerAddress() to place the order address on the customer profile. If you want to be able to find the customer addresses again the customer needs to be logged in as a member. Otherwise there will be no link between the first purchase and the second.
uCommerce will automatically populate the address fields from the order address if they were previsouly entered on the order itself. Naturally this won't work between purchases becuase we're dealing with a completely new basket.
how to insert "billing" or "shipment" address based on logged-on user ?
Hi,
How can we insert "billing" or "shipment" address when the address.aspx is accessed using AddressInformation[XSLT].xslt .
can any one explain the logic behind populating the addresses based on logged-on user, making a selection like "billing or shipment" from dropdown as shown in UcommerceDemo store.
Regards,
Naveen
You can update Shipping and Billing using either:
CommerceLibrary:EditShipmentInformation or CommerceLibrary:EditBillingInformation.
If you want to use a stored address you can use CommerceLibrary:EditCustomerAddress to create a new address for the customer currently logged in for later use.
Hope this helps.
Hi Soren,
Thanks for the reply.
I am not getting how to pre-populate the billing or shipping address...
as mentioned in AddressInformation[XSLT].xslt...of ucommerce Demo store....
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:CommerceLibrary="urn:CommerceLibrary"
exclude-result-prefixes="msxml umbraco.library CommerceLibrary">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="basket" select="CommerceLibrary:GetBasket()/purchaseOrder" />
<xsl:variable name="billingAddress" select="$basket/billingAddress/address" />
<xsl:variable name="shipmentAddress" select="$basket/shipments/shipment/address" />
<xsl:template match="/">
<xsl:apply-templates select="$basket/addresses" mode="json" />
<form method="post" action="/shop/checkout/shipping.aspx" id="mainForm">
<table style="float:left;margin-right:20px;">
<tr>
<td colspan="2">Billing address</td>
</tr>
<xsl:apply-templates select="$basket/addresses" />
<tr>
<td>First name:</td>
<td>
<input type="text" name="firstNameInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@firstName" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Last name:</td>
<td>
<input type="text" name="lastNameInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@lastName" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Company:</td>
<td>
<input type="text" name="companyInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@company" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Street:</td>
<td>
<input type="text" name="line1Input">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@line1" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="text" name="line2Input">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@line2" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Postal code:</td>
<td>
<input type="text" name="postalCodeInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@postalCode" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="cityInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@city" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Country:</td>
<td>
<select name="countryInput">
<xsl:for-each select="CommerceLibrary:GetCountries()/countries/country">
<option>
<xsl:attribute name="value">
<xsl:value-of select="@countryId"/>
</xsl:attribute>
<xsl:if test="@name = $billingAddress/@country">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@name"/>
</option>
</xsl:for-each>
</select>
</td>
</tr>
<tr>
<td>Attention:</td>
<td>
<input type="text" name="attentionInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@attention" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>E-mail:</td>
<td>
<input type="text" name="emailInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@emailAddress" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input type="text" name="phoneInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@phoneNumber" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Mobile phone:</td>
<td>
<input type="text" name="mobileInput">
<xsl:attribute name="value">
<xsl:value-of select="$billingAddress/@mobilePhoneNumber" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td colspan="2">
Use different shipment address: <input type="checkbox" id="showShipment" name="showShipment" value="1" />
</td>
</tr>
</table>
<table id="shipmentTable">
<tr>
<td colspan="2">Shipment address</td>
</tr>
<tr>
<td>First name:</td>
<td>
<input type="text" name="shipment_firstNameInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@firstName" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Last name:</td>
<td>
<input type="text" name="shipment_lastNameInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@lastName" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Company:</td>
<td>
<input type="text" name="shipment_companyInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@company" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Street:</td>
<td>
<input type="text" name="shipment_line1Input">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@line1" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="text" name="shipment_line2Input">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@line2" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Postal code:</td>
<td>
<input type="text" name="shipment_postalCodeInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@postalCode" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="shipment_cityInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@city" />
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>Country:</td>
<td>
<select name="shipment_countryInput">
<xsl:for-each select="CommerceLibrary:GetCountries()/countries/country">
<option>
<xsl:attribute name="value">
<xsl:value-of select="@countryId"/>
</xsl:attribute>
<xsl:if test="@name = $shipmentAddress/@country">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@name"/>
</option>
</xsl:for-each>
</select>
</td>
</tr>
<tr>
<td>Attention:</td>
<td>
<input type="text" name="shipment_attentionInput">
<xsl:attribute name="value">
<xsl:value-of select="$shipmentAddress/@attention" />
</xsl:attribute>
</input>
</td>
</tr>
</table>
<input style="clear:both;display:block;" type="submit" value="Proceed to shipping"></input>
<div>
<a href="/shop/checkout/cart.aspx">Back</a>
</div>
</form>
<xsl:text disable-output-escaping="yes">
<![CDATA[
<script type="text/javascript">
insertAddress = function () {
var selectedAddressId = $("#addressTemplate option:selected").val();
if(!selectedAddressId) return;
var jsonText = $("#jsonAddresses").text().replace('}\,]}', '}]}');
var myJsonObject = eval('(' + jsonText + ')');
var selectedAddress = jQuery.grep(myJsonObject.address, function (a) { return a.addressId == selectedAddressId; })[0];
$("form input[name=firstNameInput]").val(selectedAddress.firstName);
$("form input[name=lastNameInput]").val(selectedAddress.lastName);
$("form input[name=emailInput]").val(selectedAddress.emailAddress);
$("form input[name=phoneInput]").val(selectedAddress.phoneNumber);
$("form input[name=mobileInput]").val(selectedAddress.mobilePhoneNumber);
$("form input[name=companyInput]").val(selectedAddress.company);
$("form input[name=line1Input]").val(selectedAddress.line1);
$("form input[name=line2Input]").val(selectedAddress.line2);
$("form input[name=postalCodeInput]").val(selectedAddress.postalCode);
$("form input[name=cityInput]").val(selectedAddress.city);
$("form input[name=countryInput]").val(selectedAddress.country);
$("form input[name=attentionInput]").val(selectedAddress.attention);
}
showShipment = function() {
if($("#showShipment").attr('checked')){
$("#shipmentTable").show();
}else{
$("#shipmentTable").hide();
}
}
$(document).ready(function() {
$("#shipmentTable").hide();
$("#addressTemplate").change(insertAddress);
$("#showShipment").click(showShipment);
});
</script>
]]>
</xsl:text>
</xsl:template>
<xsl:template match="purchaseOrder/addresses" >
<tr>
<td>Addresses:</td>
<td>
<select name="addressTemplate" id="addressTemplate">
<option value="">Select...</option>
<xsl:apply-templates select="address" />
</select>
</td>
</tr>
</xsl:template>
<xsl:template match="address" >
<option value="{@addressId}">
<xsl:value-of select="@addressName"/>
</option>
</xsl:template>
<xsl:template match="purchaseOrder/addresses" mode="json">
<div id="jsonAddresses" style="display:none;">
<xsl:text>{"address": [</xsl:text>
<xsl:apply-templates select="address" mode="json" />
<xsl:text>]}</xsl:text>
</div>
</xsl:template>
<xsl:template match="address" mode="json">
<xsl:text >{</xsl:text>
<xsl:text>"firstName":"</xsl:text>
<xsl:value-of select="@firstName"/>
<xsl:text>", "lastName":"</xsl:text>
<xsl:value-of select="@lastName"/>
<xsl:text>", "emailAddress":"</xsl:text>
<xsl:value-of select="@emailAddress"/>
<xsl:text>", "phoneNumber":"</xsl:text>
<xsl:value-of select="@phoneNumber"/>
<xsl:text>", "addressName":"</xsl:text>
<xsl:value-of select="@addressName"/>
<xsl:text>", "mobilePhoneNumber":"</xsl:text>
<xsl:value-of select="@mobilePhoneNumber"/>
<xsl:text>", "company":"</xsl:text>
<xsl:value-of select="@company"/>
<xsl:text>", "line1":"</xsl:text>
<xsl:value-of select="@line1"/>
<xsl:text>", "line2":"</xsl:text>
<xsl:value-of select="@line2"/>
<xsl:text>", "postalCode":"</xsl:text>
<xsl:value-of select="@postalCode"/>
<xsl:text>", "city":"</xsl:text>
<xsl:value-of select="@city"/>
<xsl:text>", "state":"</xsl:text>
<xsl:value-of select="@state"/>
<xsl:text>", "country":"</xsl:text>
<xsl:value-of select="@country"/>
<xsl:text>", "addressId":"</xsl:text>
<xsl:value-of select="@addressId"/>
<xsl:text>", "attention":"</xsl:text>
<xsl:value-of select="@attention"/>
<xsl:text>"},</xsl:text>
</xsl:template>
</xsl:stylesheet>
how to pre-populate the address of logged in customer when he access address.aspx page in ucommerce demo store...using above AddressInformation[XSLT]...
Please provide any input....
Regards,
Naveen
I'm having the same problem. I'm using Umbraco 4.9 and UCommerce 2.6.1.0. I complete the order, customer is created and UCommerce_OrderAddress table is populated. Later when placing order with the same customer and using CommerceLibrary:GetBasket() i get empty address element. Also the table UCommerce_Address is empty. Can you explain what i'm doing wrong?
Thanks,
Almir
Looks like you need to use the CommerceLibrary:EditCustomerAddress() to place the order address on the customer profile. If you want to be able to find the customer addresses again the customer needs to be logged in as a member. Otherwise there will be no link between the first purchase and the second.
uCommerce will automatically populate the address fields from the order address if they were previsouly entered on the order itself. Naturally this won't work between purchases becuase we're dealing with a completely new basket.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.