1

sorry I posted this in the google group before I realized you had moved this type of question to stackoverflow

I'm developing a web app with an e-commerce component based on shopify as a white-labelled product for our clients. Our app allows our clients' customers to purchase a subscription to a product for use within the app. Each of our clients will have a separate shopify store. We have a web interface that allows our clients to create products and we use the shopify api to create the products in their store via an app. We have installed web hooks to receive notification of payments so that we can create the appropriate records in our system to allow the customer access to the product they purchased.

So far, the plan has been to provide a product list on our site with a 'Buy Now' button that adds the product to the store's cart and then direct the user to checkout using Shopify's checkout system. In the fulfillment web hook, we get the cart token so all we need to do to link the two systems is record the cart token temporarily in our customer database and then we can credit the right user with the purchase.

The problem that we are running in to is that there seems to be no way to link the cart / order / payment to the user that is actually logged in to our system. We are still under development so we are using test stores and the domain of the app is different from the domain of the store (and that may be the case in the production system too) and it is seemingly impossible to figure out how to link the two systems.

I have tried a couple of different approaches ...

1) use a form and post to the store's cart/add.js with a return_to=back

This seems successful in that the items are added to the cart and opening the cart in a new window takes them to the cart they added the item to, but there is no way to associate that cart with the user on our system since we can't access the cart token in a separate domain

2) use a proxy (our system is written in nodes) to post to the store's cart and intercept the cart token.

This also works in that an item is added to a cart and we can access the _session_id and cart cookies from the response, but I don't seem to be able to set those cookies in the browser. Going to the store's cart doesn't show the item just added and the store gets a different cart token.

Is there a different approach or should one of those work?

Should we be doing this entirely differently?

Cheers

Paul

4

2 に答える 2

2

最善の策は、注文が作成されたときにカート属性に何かを入れ、Webhookを取得して注文を他のシステムにリンクするときにそれを使用することです。他のサーバーに単純なjsonエンドポイントを設定して、現在ログインしているユーザーを取り戻すか、カートページにあるユーザーを入力してカート属性に保存することができます。カート属性の詳細http://wiki.shopify.com/Ask_customer_for_additional_information

于 2012-06-30T13:30:40.033 に答える
1

Johnの提案を実装するために、次をcart.liquidファイルに入れました。

<script type="text/javascript">
(function($){
    $(document).ready(function(){
        $.ajax({
            url: 'http://<server>/token',
            dataType: 'jsonp',
            success: function(data, status, xhr) {
                $('#cartform').append('<input type="hidden" name="attributes[token]" value="'+data.token+'" />');
            },
            error: function(xhr, status, error) {
                alert('Error');
            }
        });
    });
})(jQuery);
</script>

私のサーバーはショップとは異なるドメインで実行されているため、jsonpを使用しています。トークンは、データベース内の顧客レコードを一意に識別するために使用できるものです。私は属性を使用しているので、クライアントが自分で何かに使用したい場合に、shopifyのメモ機能の使用と競合しないようにしています。私はまだこれを私のWebフックでテストしていませんが、これからこの作業を行うことができると思います。

Shopifyがシステムで動作するためには、クライアントがこれをテンプレートに入れる必要があるため、これには完全には満足していません。それでも、JSON / cart APIを使用して、カートのメモの値を設定する方法があるはずだと思います。

于 2012-07-05T19:38:51.660 に答える