Hi I am creating order from other platform to wordpress. The customers that were subscribed offline but need to be put on woocommerce. but it is not full filling one thing in the column automatically.
The first row is created with api. it shows me the total amount of the order but i cannot find how will this field be populated. my code for created new order
billing_info = {
'first_name': row.firstName,
'last_name': row.lastName,
'email': row.email,
}
line_items = []
line_items.append(
{
'product_id': businessCreditProductId,
'quantity': 1,
'subtotal': row.amount,
'total': row.amount,
'price': float(row.amount),
})
wcapi.post('orders', data={
'customer_id': userId,
'line_items': line_items,
'status': 'completed',
'billing': billing_info,
})
Related
I am writing the payment code in the sandbox of paddle using nestjs and html.
I made two products, a regular product and a plan.
If I paid for the plan, I could receive checkout_id information from the webhook.
However, when purchasing a general product, the following information was obtained through the webhook.
{
event_time: '2022-08-22 08:54:19',
p_country: 'CN',
p_coupon: '',
p_coupon_savings: '0.00',
p_currency: 'CNY',
p_custom_data: '',
p_earnings: '{"7668":"3.2000"}',
p_order_id: '407118',
p_paddle_fee: '3.77',
p_price: '6.97',
p_product_id: '33625',
p_quantity: '1',
p_sale_gross: '6.97',
p_tax_amount: '0.00',
p_used_price_override: '0',
passthrough: '{"userId":9}',
quantity: '1',
p_signature: 'bZhkDR+M/G...HIU+D8ZaQ9BKMGL2a/K63eoAdkU='
}
And on the order page, I selected the quantity as 3, the quantity is 1 and the webhook is called 3 times...
//sandbox
Paddle.Environment.set('sandbox');
Paddle.Setup({
vendor: xxxx,
eventCallback: function (data) {
// The data.event will specify the event type
if (data.event === 'Checkout.Loaded') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Complete') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Close') {
console.log(data.eventData) // Data specifics on the event
}
}
});
Paddle.Checkout.open({
product: xxxxx
, allowQuantity:true
, passthrough:{
userId:9
}
});
Above is my html code. The eventCallback function is not called on that page.
Is it a sandbox issue? Please let me know how I can solve the above problems!
[summary]
I want to get checkout_id through webhook in general product payment.
If I select quantity 3 when paying for a product, the quantity is displayed as 1 in the webhook and the webhook is called 3 times.
The eventCallback function is not called in the html.
I am trying to add a search filter for a custom line item field in a suitelet and it is returning no results.
function getExpenseSearch(soNum){
log.debug('getExpenseSearch entered')
log.debug('soNum: ' + soNum)
var billSearch = search.create({
type: 'transaction',
filters: [
[ 'type', search.Operator.ANYOF , ['VendBill']], 'and',
['mainline', search.Operator.IS,['F']], 'and',
['custcol_connected_so', search.Operator.ANYOF, [soNum]] ///<=== this is the problem why is it not registering?
],
columns: ['trandate',
'tranid',
'amount'
]
}).run().getRange({start: 0, end: 100})
log.debug('return billSearch[0].tranid: ' + billSearch[0].tranid) //<== always undefined
return billSearch
}
I have isolated the problem to the sublist field
custcol_connected_so is a List field (of sales orders)
soNum is the netsuite internal id of the record
I have already tried the following:
changed .IS to to .ANYOF
used TEXT value instead of recID
hardcoded the correct recID
used 'expense.custcol_connected_so (and other variations, shot in the dark)
input different syntax for create filter
In the records browser there is no join table for the vendorBill so I would think just the custcol_connected_so filter should work fine.
Taking another look there are a couple of issues.
Your syntax for getting the tranid is incorrect (or at least not supported) and you would not be able to get the mainline amount with a single query because you are only going to be able to return the line level amount. In the example below you could use ref.id to load the sales order or to do a lookup Fields call:
This works in my account:
require(['N/search'], search=>{
search.create({
type:'creditmemo',
filters:[
['mainline', 'is', 'F'], 'AND',
['custcol_linked_transaction', 'anyof', [2403605]]
],
columns:['tranid', 'custcol_linked_transaction']
}).run().each(ref=>{
console.log(ref.id, ref.getValue({name:'tranid'}), ref.getValue({name:'custcol_linked_transaction'}));
return false;
});
});
If soNum is the visible sales order number you'd need to get the SO's internal id in order to run that search. Consider:
function getExpenseSearch(soNum) {
log.debug('getExpenseSearch entered')
log.debug('soNum: ' + soNum)
var soInternalId = null;
search.create({
type: 'salesorder',
filters: ['tranid', 'is', soNum]
}).run().each(function(ref) {
soInternalId = ref.id;
return false;
});
var billSearch = search.create({
type: 'vendorbill',
filters: [
['mainline', 'is', 'F'], 'and',
['custcol_connected_so', 'is', soInternalId] ///<=== this is the problem why is it not registering?
],
columns: ['trandate',
'tranid',
'amount'
]
}).run().getRange({
start: 0,
end: 100
})
log.debug('return billSearch[0].tranid: ' + billSearch[0].tranid) //<== always undefined
return billSearch
}
I have a flask application that makes a call to my API to pull down some records. I then pass the json response to json2html, then to datatables to create a table. I plan on creating a button on my table with row select option.
My question is, can I use the data on my table to populate a form on another page? Effectively I want to be able to select the row, click update button which takes me to a form page with the form values populated from the row values. So if click row 1, and my form page with be populated,
id = 6a3d7026-43f3-67zt-9211-99dfc6fee82e
name = test
description = test
number = 20934120
....some other fields not from the table
I am not sure how I can achieve this without a database. Not looking for a full solution just some pointers on the best methods or some good documentation. Thanks
example response
{'count': 2, 'total': 2,
'data': [
{'id': '6a3d7026-43f3-67zt-9211-99dfc6fee82e',
'name': 'test',
'properties': {'Description#en': 'test', 'Number#en': '20934120'},
{'id': '6a3d7026-43f3-67zt-9211-99hdttbhh4ed',
'name': 'test',
'properties': {'Description#en': 'test', 'Number#en': '20934121'}}],
inside app.py
....REQUEST
response = requests.request("GET", url, headers=headers, data=payload)
data = json.loads(response.text)
output = json2html.convert(json = data, table_attributes="id=\"table1\" class=\"table1\")
return render_template("update.html", data=data, output=output)
inside update.html
{{output|safe}}
<script>
$(document).ready(function() {
$('#table1').DataTable( {
"searching": false,
dom: 'Bfrtip',
buttons: [
{
text: 'Update',
action: function ( e, dt, node, config ) {
alert( 'This is my button' );
}
}
]
} );
} );
</script>
I have a DynamoDB table which contains objects looking like the following:
{
'username': ...,
'subscriptions': [
...
],
...
}
And I would like to filter subscriptions for each user based on some criteria, and get back the objects which have subscriptions matching the criteria, but filter those objects so that only the matching subscriptions are present.
If a user has subscribed to 50 things, but only 3 of them match, I would like to get back an object where the `subscriptions' field is only 3 elements long. I also need the other information contained in the object.
To give a more specific example, suppose that I have two elements in my table:
{
'username': 'alice',
'subscriptions': [
1,
2
],
'email': 'alice#a.com'
},
{
'username': 'bob',
'subscriptions': [
2,
3
],
'email': 'bob#a.com'
}
And I would like to filter to get the subscription `1'. I would like to get back
{
'username': 'alice',
'subscriptions': [
1
],
'email': 'alice#a.com'
}
Or perhaps some other structure which contains all the necessary information (and no other information in order to save bandwidth).
I believe I can do this with scan(), but I do not know the specifics.
I have a Customer Refund record and now I need to find the associated Customer Deposits records? I've looked in the SuiteScript Records Browser but I don't see the data field in there to connect them.
Thanks,
Russ
If you are still trying to deal with the deposits for a particular sales order you can do a simple search:
nlapiSearchRecord('customerdeposit', null, new nlobjSearchFilter('createdfrom', null, 'is', 1217));
//1217 is internal id of original sales order
However if you are still questing to refund a particular deposit you should also know that the means of creating the customer refund properly is still undocumented:
var cr = nlapiCreateRecord('customerrefund',{entity:127}); // id of customer
cr.setFieldValue('paymentmethod', 1);
//may need to cycle through deposit lines to find the right one(s)
//cr.setLineItemValue('deposit', 'doc', 1, '1226');
//cr.setLineItemValue('deposit', 'amount', 1, 500);
cr.setLineItemValue('deposit', 'apply', 1, 'T'); // need this for at least one line.
nlapiSubmitRecord(cr);
And then if you want to find the affected deposit again it's quite odd. If you can start with the refund's document number you'd collect the ids of the transactions that apply it and then get the transactions that those apply to:
var appliedIds = nlapiSearchRecord('customerrefund', null, [new nlobjSearchFilter('tranid', null, 'is', '2073'),
new nlobjSearchFilter('applyingtransaction', null, 'noneof', ['#NONE#'])
], [
new nlobjSearchColumn('tranid'),
new nlobjSearchColumn('applyingtransaction'),
new nlobjSearchColumn('applyinglinktype')
]).map(function(cr) {
console.log(cr.getValue('deposit', 'applying'));
console.log(cr.getValue('applyinglinktype'));
if ('payment' == cr.getValue('applyinglinktype')) {
return cr.getValue('applyingtransaction');
}
return null;
}).filter(function(id) {
return id;
});
nlapiSearchRecord('depositapplication', null, [
new nlobjSearchFilter('internalid', null, 'anyof', appliedIds),
new nlobjSearchFilter('appliedtolinktype', null, 'anyof', ['DepAppl'])
], new nlobjSearchColumn('appliedtotransaction')).
forEach(function(da) {
console.log(da.getValue('appliedtotransaction'));
});