How to put a postcode look up to my cs-cart address form making an add-on? - cs-cart

I want to put a postcode look up to my cs-cart address form where customers can come and enter their postcode and I'll suggest the addresses on the basis of that.
I already have written the API, but what are the files in cs-cart structure that needs to be modified to put this look up in place?

CS-Cart has a very good documentation for this (including examples & example addons). Take a look at the following webpages:
https://docs.cs-cart.com/4.8.x/developer_guide/addons/hooking/index.html
https://docs.cs-cart.com/4.8.x/developer_guide/addons/tutorials/index.html

You can simply use jQuery .keyup event, please be aware that are 2 fields for postal code, one for billing and one for shipping
$("#elm_28").keyup(function() {
alert( $(this).val() );
});

Related

What code should I add (and where) on my website to track events/identify users on my website using segment.com?

I want to configure segment.com properly on my site and use it to manage all other apps/tools. I already installed the segment javascript on my site and used it as the source. Now, I am pushing these to MixPanel, Facebook, Google Analytics, etc.
What code should I add if I want to track an event and/or identify a user?
For simplicity's sake, i have a landing page (site.com/landing-page) with a form. After a successful submission, it redirects to a thank you page (site.com/thank-you-page).
The default settings already track the page views, and are pushing that same event to the different tools (FB: PageView, MixPanel: Loaded a Page, etc).
But in this case, i want to track the event and capture the person's information. And i don't know what to code to add and where.
My research so far
According to this article:
The best way to track new users is in client-side javascript on the welcome page after they signup, below we’ll explain why.
So, based on that, I add the code to my thank you page. But where? Header like adding GA scripts? body tag? I can add it anywhere, but i don't know where.
Next is what code should I add?
The example from the same article above:
When a new visitor goes to their site that visitor is anonymous. As soon as the visitor connects their Facebook account, Rdio knows who they are and creates a user record.
As part of that new user record the person is assigned a userId. Let’s say the new userId is 12345. Rdio will then need to fire the following calls on the welcome page:
analytics.identify('12345',{ name:'Jake Peterson', email:'friends#segment.com'});
analytics.track('Account Created',{ authentication:'Facebook'})
This gives me two problems: track and identify.
Track Problem
I'll start with the track. Based on how I understood this, assuming the event name i want to be added is "Downloaded PDF" then I want to store the title of it as well. It should look like this, right?
<script>
analytics.track('Downloaded PDF', {
title: 'Awesome Title'
});
</script>
Am I correct to enclose them inside <script> tags?
The tracking of an event seems a bit easier to understand that the identify part. But would love to know if i got that part right.
Identify Problem
Here, i have two questions:
where does userId come from? Is it automatically generated? For example, inside my MixPanel account, i see them. Is that what i use?
How do i reference to the userId? or any of the other traits I want to track in my code?
Taking from the same example above:
analytics.identify('12345',{ name:'Jake Peterson', email:'friends#segment.com'});
If i add this exact code on my thank you page, every signup will be assigned those values: '12345', 'Jake Peterson', and 'friends#segment.com', right?
What code should I add to (1) assign them the right userId (2) and get the name and email traits from the form of the previous page.
Let's say i'm only collecting first name and email.
analytics.identify("userId"{ firstName:"firstName", email:"email"});
If I add this code to my thank you page, will it automatically assign the userId, firstName, email values of the form that was submitted? That's the part I don't understand. What code to add to dynamically push the correct data.
And i know i'm not even adding the Alias part for MixPanel yet, but i just want to understand this part and the rest (hopefully) will be easier to understand.

Can I obtain the country name with Google Places API?

On the request for current place I receive a list of places. Every place has an address but that address is a string so I can't get only the country name.
Could someone help me on this matter?
Country is only explicitly available when using the Place Details API, not the Places API. (https://developers.google.com/maps/documentation/places/web-service/details)
You first need to look up a place_id for the specific place you're looking for. You then use your place_id to pull details from the Details API, which includes information like:
Fully formatted address, including country
Address components
Sample reviews
Phone # and website
Operating hours
If you have read the Google Places Autocomplete doc,you must know about API properties.you can use the type as '(region)' and will return you many results (plus country).And if you look inside address_components field (it's array with dynamic length),you will see,that the last item of array is what you need.Here is a great page to read a correct doc and try examples yourself.
http://www.w3docs.com/learn-javascript/places-autocomplete.html

custom routing in magento

I have multi store views in website,
The current URL for a category for the dutch store view would be;
http://www.domain.ext/nl/category.html,
http://www.domain.ext/de/category.html etc
Now I want to add country code with store code. I mean to say, I am getting country code from Users Ip and want to extend it with store code. It will be look like
If the country is set to NL the URL should now be;
http://www.domain.ext/nl_nl/category.html
If the storeview is Dutch (NL) but the country is Belgium (BE), the URL should become;
http://www.domain.ext/nl_bel/category.html
I want this only in category page. I am trying to change in match function of standard.php, but I think its role starts from controller name, please help me how can I achieve it. Any help is highly appreciated.
Are you sure you want to incorporate it into the URL like that?
I think you are going to fight a lot of Magento code to achieve it (product url, catalog url, indexing, getUrl functions and collections, rewrites).
I'm sure you have considered this and the many ways to do what you want but I think you are making work for yourself. Perhaps adding the country code as a URL query string ?c=bel or keeping it all internal to Magento by storing it in a session variable or a general function that you can call at any time eg getCustomCountryCode(). Using a cookie might be a possibility too.
If the URL is purely cosmetic then perhaps an .htaccess rewrite would suffice combined with some rel='canonical' href="http://www.domain.ext/nl_bel/category.html" on the category pages.
If you are determined to proceed then study the class Mage_Catalog_Model_Url

Aliasing ID parameter in URL as string in ASP.NET MVC 4

What i'm trying to do is to rewrite URLs to make them more SEO friendly but i still want to pass a parameter as an int ID.
For example, a URL pointing to a news article might look like this:
"www.domain.com/category-id/article-id" or "domain.com/5/3"
What i want to do is to rewrite the URL everywhere so that the title of the category and the title of the article are written into the URL so it becomes f.x. "domain.com/politics/some-title" but i still want to pass the ID of the article as an argument to the controller action. This is less important for the category but it's something i want to do with the article-id since it's unique but the title might not be.
I have checked out Attribute Routing and looked through some Routing guides and questions but haven't found anything that lets me implement this functionality. I've just started using ASP.NET MVC so i haven't been able to look into anything too advanced.
Thanks in advance.
I would advice to make the article title unique and from the controller action you have to get the article based on the title.
I see you are trying to group the articles based on category. When I initially created my blog I thought the same-thing but soon realized it's not a flexible approach because of couple of reasons.
Say you wrote one article with name some-title and dropped it under a category say politics and so the url will be domain.com/politics/some-title but at a later point of time you thought to move the article to another category say 'international-politics' therefore your url now has to be changed to domain.com/international-politics/some-title and you break the old url and whoever has bookmarked that link will now receive 404. A better way would be organize the urls based on the posted date and that's not going to change something like http://domain.com/archive/yyyy/mm/dd/unique_title
Sometimes you want to label an article with more than one category and at that time a tag based approach will become a better choice compared to category based approach.
Quick and dirty solutions:
1) domain.com/categoryName/articleID/articleName/
2) domain.com/date/categoryName/articleName (date should help make articleName unique)
3) domain.com/categoryName/articleName?id=xxx
Nothing fancy, but those approaches will work.

How add custom field in cart and sent in the order

I have one question about shopping. I need aggregate one field Giftwrapped your order? Yes No. name=giftwrap id=giftwrap value=functionevalue(Radio) this validation is javascript and function, no problem with this. Now i have take the value giftwrap and send to group ajax and show this value in checkout review before confirm order, and then send the comment: the gift should be wrapped in the orden in the backend. I try, i search but no nothing functioned, please help.
Take a look at this Order Attributes extensions. It does exactly what you want for a relative cheap cost.

Resources