Shopify Checkout script get cart attribute - shopify

I'm using shopify plus store.
I want to access cart attributes in checkout script editor.
Is there any way to get cart attributes in checkout script editor?
{
token: "18da3b31a1b1d045500ad49e17836d5a",
note: "",
attributes: {
simply_test: "1"
},
original_total_price: 2900,
total_price: 2900,
total_discount: 0,
total_weight: 0,
item_count: 1,
items: [..],
requires_shipping: true,
currency: "USD"
}

Yes, it is possible
<script>
// Get cart values
$.getJSON( "/cart.js")
.done(function( response ) {
console.log(response);
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});
// Update cart values
$.post('/cart/update.js', {
attributes: {
'Gift wrap': 'maybe',
'Name': 'Johnny Deep',
}
});
</script>

This should get you the cart attributes anywhere on Shopify:
await fetch('/cart.js', {
method: 'GET'
})

I would adjust your shop so that you transfer the info you store in cart attributes as line item properties. Those do transfer to checkout scripts. Does not look good for cart note or attributes.

Related

Netsuite Rest API Create Non-inventory Item for Sale

I try to create a Non-Inventory Sale item with the NetSuite API.
Here is my request :
Method : POST
Endpoint: /services/rest/record/v1/nonInventorySaleItem
Payload:
{
"itemId": "Test Item",
"IncomeAccount": {
"id": "1315"
},
"deterredRevenueAccount": {
"id": "1343"
},
"itemType": {
"refName": "NonInvtPart"
},
"location": {
"id": "46"
},
"taxSchedule": {"id": "1"}
}
It keeps returning 400 HTTP Error and the message :
Error while accessing a resource. Please enter value(s) for: Tax Schedule.
I tried to work around with a custom entity field and a UserEventScript SuiteScript to update taxSchedule before submit without success.
I spoke with NetSuite support staff and they basically said that the feature isn't supported. If you want you can create a RESTlet and recreate the functionality by accepting the parameters that you want and creating the item that way. Something roughly like this:
define(['N/record'], function(record) {
function post(context) {
if (context.request.method !== 'POST') {
throw {
status: 405,
message: 'Invalid HTTP method',
};
}
// Parse the request body
var requestBody = JSON.parse(context.request.body);
// Create the inventory item record
var itemRecord = record.create({
type: record.Type.INVENTORY_ITEM,
isDynamic: true,
});
// Set the item name, tax schedule, asset account, and cogs account
itemRecord.setValue({
fieldId: 'itemid',
value: requestBody.name,
});
itemRecord.setValue({
fieldId: 'taxschedule',
value: requestBody.taxSchedule,
});
itemRecord.setValue({
fieldId: 'assetaccount',
value: requestBody.assetAccount,
});
itemRecord.setValue({
fieldId: 'cogsaccount',
value: requestBody.cogsAccount,
});
// Save the inventory item record
var itemId = itemRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true,
});
// Return the new inventory item ID
return {
id: itemId,
};
}
return {
post: post,
};
});
Obviously also include any other fields that you want, but I found that the Tax Schedule, COGS account, and asset accounts were all required.

Prestashop JS script tracking confirmation order page

I have a problem.
I need to deploy a tracking script for a partner to track orders. He sent me this:
<script>
var dcData = {
event: 'sel',
clear: 1,
price: '<price>',
cdata: {
orderNumber: '<ordernumber>',
email: '<email>',
},
}
digitalCircle('event', dcData);
</script>
It doesn't work after putting it in the confirm page.
Hello,
I have a problem.
I need to deploy a tracking script for a partner to track orders. He sent me this:
var dcData = {
event: 'sel',
clear: 1,
price: '',
cdata: {
orderNumber: '',
email: '',
},
}
digitalCircle('event', dcData);
It doesn't work after putting it in the confirm page.

Updating the image in laravel 8 + inertia, validation error even the fields are filled

I'm working with Laravel 8 + inertiajs. I can create a product with or without an image. But when I try to update a product and upload a new image, the validation looks for the required field even they're already filled.
here is my input field:
<input name="images" type="file" #input="form.images = $event.target.files[0]" />
in my vue:
props: {
product: Object,
categories: Array
},
data() {
return {
form: this.$inertia.form({
name: this.product.name,
category_id: this.product.category_id,
description: this.product.description,
date: this.product.date,
images: this.product.images
})
}
},
methods: {
update() {
this.form.put(this.route('products.update', this.product.id, {
preserveState: true
}))
},
}
})
my update controller:
public function update(UpdateProductRequest $request, Product $product)
{
$inputs = $request->validated();
if ($request->hasFile('images')) {
$filename = $request->images->getClientOriginalName();
$file = $request->images->storeAs(('images'), $filename);
$product->images = $file;
$inputs['images'] = $product->images;
}
$product->name = $inputs['name'];
$product->category_id = $inputs['category_id'];
$product->description = $inputs['description'];
$product->date = $inputs['date'];
$product->update();
session()->flash('flash.banner', 'Product Updated Successfuly');
session()->flash('flash.bannerStyle', 'success');
return redirect()->route('products.index');
}
multipart/form-data request is not natively supported in some languages for the put,patch or delete methods. The workaround here is to simply upload files using post instead.
Some frameworks, such as Laravel and Rails, support form method spoofing, which allows you to upload the files using post, but have the framework handle the request as a put or patch request. This is done by including a _method attribute in the data of your request.
Inertia.post(`/users/${user.id}`, {
_method: 'put',
avatar: form.avatar,
})

How to generate Items list with vue-paypal-checkout?

I am trying to generate an items list response from paypal checkout requests. I am trying to do it dynamically, using my data objects and some computed properties in a for in loop. As far as I have understood, my items_list will always need to be a data variable, never a hard-coded array.
Here is my template element:
<div v-bind:key="plan.key" v-for="plan in plans" >
<PayPal
:amount="plan.price" // all good
currency="GBP" // all good
:client="credentials" // all good
env="sandbox" // all good
:items="[plan]" // this is NOT working
#payment-authorized="payment_authorized_cb" // all good
#payment-completed="payment_completed_cb" // all good
#payment-cancelled="payment_cancelled_cb" // all good
>
</PayPal>
</div>
Here are my data objects on my script:
plans: {
smallPlan: {
name: 'Small Venue',
price: '6',
},
mediumPlan: {
name: 'Medium Department',
price: '22',
},
}
payment_completed: {
payment_completed_cb() {
}
},
payment_authorized: {
payment_authorized_cb() {
}
},
payment_cancelled: {
payment_cancelled_cb() {
}
},
Here are my methods:
methods: {
payment_completed_cb(res, planName){
toastr.success("Thank you! We'll send you a confirmation email soon with your invoice. ");
console.log(res);
},
payment_authorized_cb(res){
console.log(res);
},
payment_cancelled_cb(res){
toastr.error("The payment process has been canceled. No money was taken from your account.");
console.log(res);
},
The documentation of Vue-paypal-checkout is available here https://www.npmjs.com/package/vue-paypal-checkout
If I don't add the items list :items everything works perfectly:
{"id":"PAY-02N9173803167370DLPMKKZY","intent":"sale","state":"approved","cart":"90B34422XX075534E","create_time":"2018-10-30T18:39:51Z","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"joaoalvesmarrucho-buyer#gmail.com","first_name":"test","middle_name":"test","last_name":"buyer","payer_id":"JCZUFUEQV33WU","country_code":"US","shipping_address":{"recipient_name":"test buyer","line1":"1 Main St","city":"San Jose","state":"CA","postal_code":"95131","country_code":"US"}}},"transactions":[{"amount":{"total":"245.00","currency":"GBP","details":{}},"item_list":{},"related_resources":[{"sale":{"id":"2RA79134UX2301839","state":"pending","payment_mode":"INSTANT_TRANSFER","protection_eligibility":"ELIGIBLE","parent_payment":"PAY-02N9173803167370DLPMKKZY","create_time":"2018-10-30T18:39:50Z","update_time":"2018-10-30T18:39:50Z","reason_code":"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION","amount":{"total":"245.00","currency":"GBP","details":{"subtotal":"245.00"}}}}]}]}
But if I add :items="[plan]" i get this error message:
Uncaught Error: Error: Request to post https://www.sandbox.paypal.com/v1/payments/payment failed with 400 error. Correlation id: 19238526650f5, 19238526650f5
{
"name": "VALIDATION_ERROR",
"details": [
{
"field": "transactions.item_list.items.item_key",
"issue": "This field name is not defined for this resource type"
}
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "19238526650f5"
Any thoughts?
Also if you happen to know, is there a way to sell/implement a subscription instead of a one-off transaction using Vue-paypal-checkout?
Many thanks

How to programmatically delete a work item in Rally?

I'm customising cards by using a custom card renderer on a cardboard and would like to add a 'Remove' button on each card in order to do the same 'delete' functionality as provided in the Iteration Status page (i.e move the item to recycle bin).
By inspection, I can see on click the following event is fired when deleting stories from 'Iteration Status' page:
onclick="deleteAR({itemOid:'1234', name:'Item name', formattedID:'Item001', msg:'Are you sure?'}); return false;"
Edit: I'm using JDK 1.3
You should be able to delete in SDK 1.x like so:
function delete(ref, callback, errorCallback) {
var config = {
url: ref,
content: {},
headers: { "Content-Type": "application/json" },
handleAs:"json",
preventCache: true,
load: callback,
error: errorCallback
};
if (rally.sdk.util.Context.isInsideRally()) {
dojo.xhrDelete(config);
} else {
config.callbackParamName = "jsonp";
config.content._method = "DELETE";
dojo.io.script.get(config);
}
}
//delete an item
delete('https://rally1.rallydev.com/slm/webservice/1.32/defect/12345.js',
function(results) {
//success
},
function(results) {
//error
}
);
We were going to expose this functionality via rally.sdk.data.io.httpDelete and rally.sdk.data.RallyDataSource.delete but never fully tested and released it.