Prestashop - realize cart created on external site by webservice - web-services

Im using Prestashop webservice to manage cart on external site. I can create/update/delete cart and products by API, all works fine. My next step is add "realize" button, which redirect to the main shop, where user will by able to realize that cart. How can I created cart on external site show on shop? It is possible?
I will be grateful for help.

You can create a cart using webservices and add products to it. The problem is that when you redirect client to shop, even if this cart already exist in DB, shop cookies must be set and inside this encrypted Prestashop cookie should be the cart ID. So, I think you won't be able to do that.
Good luck.

Yes, that is the point. Maybe is not a perfect solution, but found the way, how to display cart created by webserice on external site.
By webservice, I created cart and order for temporary user. In history order of that user is link "reorder", whitch looks like:
http://your_presta_shop/zamowienie?submitReorder=&id_order=X
If you copy and paste that link on the any browser, you see your cart created by API.

A bit late, but hope it helps someone.
There's a way to recover a cart (tested on 1.6.18). You can use the following URL:
http://(your_shop)/order?step=3&recover_cart=(id_cart)&token_cart=(token)
id_cart is the id of your cart :)
token is calculated as follows: md5(_COOKIE_KEY_.'recover_cart_'.$id_cart); (_COOKIE_KEY comes from your config/settings.inc.php in your PrestaShop installation)
You can see that this URL is generated in this two files (not very DRY):
controllers/admin/AdminCartsController.php (look for recover_cart)
controllers/admin/AdminOrdersController.php (look for recover_cart)

Related

Adding custom data to Django's admin dashboard

I'm having a bit of trouble with Django again.
I have a simple e-commerce website project that I'm working on for my graduation. It sells books. I've got basic functionalities down, such as adding categories and products, client sign-ups and logins, a session-based shopping cart, a checkout page fully connected to a payment API, and an orders model to keep track of data.
My professor has asked me now to to add relevant reports in the Admin panel, talked to me a while about what would be relevant to see and all. So, I've got in mind what I'm hoping to make.
I want to have two containers in the main dashboard page, which would display some quick analytics (like, how many books the store has sold in the past seven days, how much money from sales the site has made in the past month), as well as links in the sidebar: I want each relevant app within my project to have their own reports section in the Admin panel, maybe led to from a link underneath their models. I've separated the storefront, accounts, orders, shopping cart, and checkout, for instance, in different apps
The problem is I can't really figure out how to actually... do that...
I've fiddled with the layout and templates on the admin; I've figured out how to add custom links to the admin page, and change its design elements, for instance. But I'm not sure how to link the data I want to the dashboard. It feels like the answer is right in front of me and I can't reach it...
I guess my question is, how can I add my reports to the Django admin page per app, and how can I add these containers that I want in the dashboard?
I've guessed that I have to start out by building a view for each report. So I am currently reading the Django docs on the Admin page again, as well as looking at questions similar to mine.
But any information y'all can share that could ease up this process and save me some time would be very much appreciated. Thanks so much!
PS: If it helps, I am overriding the admin templates by having all the .html pages copied on my project's templates folder - it's how I got it to display the store's header in the admin dashboard.

Django oscar paypal not working

so I am trying to set up django-oscar-paypal with django-oscar. So, everything works fine, the paypal express checkout page shows correctly, then it redirects back to the store and when i click the place order button, it redirects to an empty basket, with no transaction being recorded in the dashboard, except for the express dashboard, which shows success. My guess is there is a session loss, or I need to edit the checkout view somehow for it to post the request, but i can't find anywhere on how to do that, and copying the one from the sandbox isn't helpful. If anybody managed to make it work I would be very grateful for help.

Using iframe for an application in external websites

I have a website built in Django. One feature of this website is booking hotels. Now, my client has many agents who have websites. We want to give the facility of booking on these websites. So, I am thinking to use iframe on these websites( with the consent of the respective agent owners), which will point to the booking page of our website. Once booking is done, we will return success message and email the user. IS this a viable solution? Or, are there any other options?
thanks
One way of doing this it's creating a rest api using a helper that works with django like django-piston so your agents could work with them to perform booking.
Should be easy to add a form to any agents site with this way. Or even using ajax if the uri returns a json.
Iframes is not the way you should go I think... I also think that you need to define the API on your website and then you just do requests from the client website to your backend.

How do I dynamically create new pages in a Django wiki?

I am creating a wiki in Django where users should be able to register, login, create pages and other users who also login should be able to see all created pages and then either create new pages or edit existing ones.
I have already created registration and login pages and I am fine with creating and editing content on pages. My question is - do any of you (who know Django) know how I can implement the create new pages into my site? I think it will be in a "form" form where you then specify the URL, title, and content of the new page, but how do you actually create the new pages then and be able to view all created pages to any user?
I am stuck at this wall and any help would be appreciated!
At the time of page create with the form that you mentioned, if the user is logged in, you will want to store the user ID as a foreign key in your page Model. Then when you go to display created pages for a specific user, you just follow the relationship.
This was posted a long time ago, so you will probably just want to use this Django App as it solves all of this for you, in one beautiful package:
https://github.com/benjaoming/django-wiki
Have you seen the tutorial here? http://showmedo.com/videotutorials/video?name=1100000
I built a wiki with that tutorial - I think even if it doesn't answer your question may still point you in the right direction. Hope it helps!

Facebook Connect: capturing user data with django-profiles and django-socialregistration

Either my google searching has completely left me or there's hardly any documentation/tutorials for django-socialregistration. Too bad, because it seems like a nice enough app. Through some trial-and-error, I have managed to get it mostly running on my site.
My question, using django-socialregistration how do I request permission for the facebook user's full name, current city and date of birth and store it in my UserProfile table (which is my AUTH_PROFILE_MODULE for django-profiles) in Django upon registration? Also, how do I post to the user's wall from Django once the connection is made?
Currently, when I click the "Connect with Facebook" button the facebook connection is made, a new Django user is created and the user is logged in with that Django account. However, no UserProfile is created and no facebook profile data is saved.
Any facebook connect gurus out there want to help the Django pony fly to Facebookland?
Setup:
- Django 1.2.1
- Python 2.5.2
- django-socialregistration 0.4.2
- django-registration 0.7
- django-profiles 0.2
"Kind sir, can you please help me find the magical Facebookland?"
In facebook_js.html you need to adjust the following line, by uncommenting items that you need to get from FB:
FB.login(handleResponse/*,{perms:'publish_stream,sms,offline_access,email,read_stream,status_update,etc'}*/);
Then, in FacebookMiddleware you can extract that data from fb_user, like this:
facebook.GraphAPI(fb_user['access_token']).get_object('me')
FWIW, I just found this moderately helpful nugget from the app author buried in the "Issues" section on github:
question from "tolano":
I have a profile model associated with the users, and everytime the user is created the profile should be created also. Should we create a new custom setup view for this purpose?
I'm finding several problems because the documentation is poor. Thank you very much.
answer from "flashingpumpkin":
Yes. Ideally you'll overwrite the setup view with your own. An easier method to adjust what is done on user creation is to pass a custom form into the setup view. You'll do that by overriding the standard url.
Here's another relevant nugget (source: http://github.com/flashingpumpkin/django-socialregistration/issues/closed#issue/7) Enough of these and this page will become the de facto django-socialregistration documentation ;)
question from "girasquid":
Maybe I'm just missing something, but I'm stuck here - is there a way to 'connect' accounts on other sites to an already-existing user?
For example, I've already signed up on Really Awesome Website, so I don't need to sign up again - but I'd like to connect my Facebook and Twitter accounts so that I can sign in with those as well.
Is there a way to do this already? If there isn't...how would I do it?
answer from "flashingpumpkin":
Yes there is. Just use the same template tags for Facebook Connect as you would for registration. Depending on if the user is already logged in or not it will create just the FacebookProfile object and link it to the existing user - or create both, the User object and the FacebookProfile object.
Have a look here:
http://github.com/flashingpumpkin/django-socialregistration/blob/master/socialregistration/templates/socialregistration/facebook_button.html
and
http://github.com/flashingpumpkin/django-socialregistration/blob/master/socialregistration/templatetags/facebook_tags.py