Getting Collection Names Of Products in Shopify - shopify

In Shopify how do I fetch names of custom collection that a particular product belongs to ?
Like for example to get SKU I can use {{ line_item.sku }} or to get Price I can use {{ line_item.line_price }}

From the API docs, to list all custom collections for a certain product_id:
GET /admin/custom_collections.json?product_id=632910392
Response:
HTTP/1.1 200 OK
{
"custom_collections": [
{
"body_html": "<p>The best selling ipod ever</p>",
"handle": "ipods",
"id": 841564295,
"published_at": "2008-02-01T19:00:00-05:00",
"sort_order": "manual",
"template_suffix": null,
"title": "IPods",
"updated_at": "2008-02-01T19:00:00-05:00",
"image": {
"created_at": "2012-12-11T12:01:29-05:00",
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/collections/ipod_nano_8gb.jpg?0"
}
}
]
}

Related

Get all API fields definitions from Podio application

Responses from Podio API returns an JSON array of items with a fields property. Each field carries its values and its config.
For example a category field for the Gender:
{
"type": "category",
"field_id": 219922852,
"label": "Gender",
"values": [
{
"value": {
"status": "active",
"text": "Prefer not to say",
"id": 3,
"color": "F7F0C5"
}
}
],
"config": {
"settings": {
"multiple": true,
"options": [
{
"status": "active",
"text": "Male",
"id": 1,
"color": "DCEBD8"
},
{
"status": "active",
"text": "Female",
"id": 2,
"color": "F7F0C5"
},
{
"status": "active",
"text": "Prefer not to say",
"id": 3,
"color": "F7F0C5"
}
],
"display": "inline"
},
"mapping": null,
"label": "Gender"
},
"external_id": "gender"
},
How can I fetch the config without having to query a specific item?
Is there a way to get every field in the response? Because if the queried item does not have a field value set, Podio doesn't return it in the response.
I would like to get the field config for ALL the fields. If possible, with a single API request. In particular I am interested in all the possible values (in case of Category or Relationship fields) so that I could match them with local values I have.
This way I can use the field structure to programmatically map some local values to the format required by the Podio API; and then generate a fields payload that to update/create Podio items via an API calls.
You can request the Podio Get App method to get the app configuration.
Podio Doc Ref: https://developers.podio.com/doc/applications/get-app-22349

BigCommerce customer attributes from client/store

Can I retrieve the customer's
There is a current-customer API - https://developer.bigcommerce.com/api-docs/customers/current-customer-api, but it only returns the following bits about a customer.
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
}
I'd really to have the ability to get all the data from
https://developer.bigcommerce.com/api-reference/customer-subscribers/v3-customers-api/customer-attributes/customersattributesget as a property of the payload for current-customer-api
/customer/current.jwt?app_client_id={appClientId}&attribute-ids:in=1,2,3
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
"attributes": [
{
"id": 1,
"name": "Age",
"type": "string",
"date_created": "2018-11-13T21:42:06Z",
"date_modified": "2018-11-14T16:46:23Z"
},
{
"id": 2,
"name": "Shoe Size",
"type": "number",
"date_created": "2018-11-14T16:34:57Z",
"date_modified": "2018-11-14T16:34:57Z"
},
{
"id": 3,
"name": "Date Joined",
"type": "date",
"date_created": "2019-02-19T19:13:21Z",
"date_modified": "2019-02-19T19:13:21Z"
}
]
}
This is an interesting feature request. The purpose of the current customer API is to verify the identity of a logged in customer in a secure way, which is why the payload is so minimal (with the understanding that you would likely be making a request for the full customer record based on the id returned).
We are planning to surface customer attribute data on the storefront though, which sounds like it would solve for your use case. We'll be adding Handlebars support soon, and we've got a storefront GraphQL API in the works as well. You can read more in our blog post here:
https://medium.com/bigcommerce-developer-blog/customize-and-extend-your-customer-data-with-the-new-bigcommerce-v3-customers-api-8609903e102a

Not Found error when charging Square API

The Square REST API docs state that I should get a list of my locations and then use a returned location code when I call the transactions endpoint (to charge a credit card). I am doing exactly this but the returned error says that the merchant has no location with the supplied ID.
I have tried this with and without the location_id in the JSON sent to the transactions endpoint, since it is a path variable. Same result. I have also seen on Square's API FAQ that the usual cause of a 404 not found is the card nonce being created wrong, but this response clearly says the location ID is not valid.
I have tested this with Postman and JSON and I can see that the location code is correct. Here are my calls and the responses:
This is a GET request:
https://connect.squareup.com/v2/locations
And here is the response:
{
"locations": [
{
"id": "FPVPFZ4DXXXXX",
"name": "MyCompany",
"address": {
"address_line_1": "123 Candy Lane",
"address_line_2": "",
"locality": "Smithfield",
"administrative_district_level_1": "RI",
"postal_code": "02917",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
},
{
"id": "4FHNAN1WXXXXX",
"name": "MyCompany2",
"address": {
"address_line_1": "567 Smith Street",
"address_line_2": "",
"locality": "Greenville",
"administrative_district_level_1": "RI",
"postal_code": "02828-2910",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
}
]
}
I modified the returned IDs a bit in the above example.
Next I make a call to charge a card to this uri:
https://connect.squareup.com/v2/locations/FPVPFZ4DXXXXX/transactions
With this body:
{
"note":"",
"idempotency_key":"azsxdcfvrtrewsdf",
"location_id":"FPVPFZ4DXXXXX",
"shipping_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"billing_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"card_nonce":"CBASEPPW7fjdUHe-3jP6ZZ4kvE0gAQ",
"reference_id":"RT-12345678",
"amount_money":{
"amount":12500,
"currency":"USD"
},
"delay_capture":true,
"buyer_email_address":"jim#xxxxxxxxxx.net",
"customer_id":"JIM"
}
And I get this response:
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "NOT_FOUND",
"detail": "This merchant does not have a location with the ID `FPVPFZ4DXXXXX`.",
"field": "location_id"
}
]
}
So the location ID matches exactly the ID returned by the locations endpoint.
Can someone familiar with this API help me out? Square's docs and support is sadly lacking.
I think the issue here is that you have tried to use your sandbox credentials (sandbox-sq0idp-defoUOlu...) to charge against your production location FPVPFZXXXXX. If you call ListLocations with your sandbox credentials, you should get a different location that you can then do sandbox charges with.

How to place an order using Magento2 API?

I am looking for the complete "happy path" to place an order using Magento2's REST API. So far these are all the steps I have followed. What else am I missing?
Create a user: [POST] /rest/V1/customers
Log In (create a token): [POST] /rest/V1/integration/customer/token
Get Product Categories for navigation: [GET] /rest/V1/categories
Get Products:
4.1 Get Category Products: [GET] /rest/V1/categories/{category_id}/products
4.2 Or search for a product: [GET] /rest/V1/products
Create a cart: [POST] /rest/V1/carts/mine
Add items to cart: [POST] /rest/V1/carts/mine/items
Get cart payment information [GET] /rest/V1/carts/mine/payment-information
...
What other things do I have to do to place the order?
create empty cart
url : http://www.xxxxxx.com/rest/V1/carts/mine
call: post
response: cartID eg: 4290
Add item to the cart
url : http://www.xxxxxx.com/rest/V1/carts/mine/items
body:
{"cartItem":{
"sku":"JFCO00017","qty":1,"name":"Devil May Cry III 3 Dante Cosplay Costume","price":81.55,"product_type":"simple","quote_id":"4290","product_option":{"extension_attributes":{"custom_options":[{"option_id":"thumbnail","option_value":"\/d\/e\/devilmaycryiii3dantecosplay_1_.jpg"},{"option_id":"color_2","option_value":"Red"},{"option_id":"google_size","option_value":"xxs"}]}}}
}
Add billling info
url : http://www.xxxxxx.com/rest/V1/carts/mine/billing-address
body:
{
"address": {
"city": "noida",
"company": "iprag",
"countryId": "IN",
"email": "manish+2#gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "201301",
"region": "UP",
"saveInAddressBook": 1,
"street": ["D-84"],
"telephone": "8802xxxx90"
},
"useForShipping": true
}
get shipping-methods
url : http://www.xxxxxx.com/rest/V1/carts/mine/shipping-methods
{
"carrier_code": "flatrate",
"method_code": "flatrate",
"carrier_title": "Flat Rate",
"method_title": "Fixed",
"amount": 10,
"base_amount": 10,
"available": true,
"error_message": "",
"price_excl_tax": 10,
"price_incl_tax": 10
}
add shipping info
url : http://www.xxxxxx.com/rest/V1/carts/mine/shipping-information
body:
{
"addressInformation": {
"billingAddress": {
"city": "noida",
"company": "iprag",
"email": "nkn#gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "335001",
"region": "UP",
"street": ["D-84"],
"telephone": "9413433217"
},
"shippingAddress": {
"city": "noida",
"company": "iprag",
"email": "nkn#gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "335001",
"region": "UP",
"street": ["D-84"],
"telephone": "9413433217"
},
"shippingCarrierCode": "flatrate",
"shippingMethodCode": "flatrate"
}
}
response: payment method and cart detail
Order place
URL : http://www.xxxxxx.com/rest/V1/carts/mine/order
body :
{
"paymentMethod":{"method":"checkmo"},
"shippingMethod":
{
"method_code":"flatrate",
"carrier_code":"flatrate",
"additionalProperties":{}
}
}
response: orderid
Ok, I finally got it right.
Save payment information and create order [POST] /rest/V1/carts/mine/payment-information

No description on approve page when I use the PayPal REST API

Using the PayPal REST API, I'm passing in this to new payments:
URL: https://api.paypal.com/v1/payments/payment
Request:
{
"intent":"sale",
"payer":{
"payment_method":"paypal"
},
"redirect_urls":{
"return_url":"[return_path]",
"cancel_url":"[cancel_path]"
},
"transactions":[
{
"amount":{
"total":"19.95",
"currency":"USD",
"details":{
"subtotal":"19.95"
}
},
"description":"[product description]"
}
]
}
But on the PayPal approve page I see no any order info. In "Your order summary" section at the left I see no description, no total, no subtotal, nothing.
Screenshot: http://goo.gl/dxoicB
But I expect to see there at lest smth...
How can I make individual items with descriptions in the REST API checkout? Or what I'm doing wrong? It seems I've read the whole Developers Guide, but there is nothing about it.
And another thing: when I done with order, in transaction details also is no any technical info about order.
Screenshot: http://goo.gl/i4iGHZ
There is no technical information allows us to understand what site and what product was sold there.
You have to specify the item_list on transactions to get order summary.
Example request data
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://return.url",
"cancel_url": "http://cancel.url"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": "1.00"
},
"description": "This is the payment description."
}]
}
Refer:
https://developer.paypal.com/webapps/developer/docs/api/#transaction-object
https://github.com/paypal/rest-api-sdk-nodejs/blob/master/samples/payment/create_with_paypal.js#L16