For a few hours i'm trying to list into paypal express checkout multiple products. This has to be done in order to increase the customers trust for what they buy.
How i can create the bellow array in order to be reconized by paypal as multiple products?
Listing of 1 product is not a problem. Here is the code:
$requestParams = array(
'RETURNURL' => '***',
'CANCELURL' => '***'
);
$item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ',
'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item',
'L_PAYMENTREQUEST_0_AMT0' => '0.01',
'L_PAYMENTREQUEST_0_QTY0' => '1'
);
$orderParams = array(
'PAYMENTREQUEST_0_AMT' => '0.01',
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'PAYMENTREQUEST_0_ITEMAMT' => '0.01',
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0'
);
$response = $core->paypal->request('SetExpressCheckout',$requestParams + $item + $orderParams);
I have tried lots of combinations like adding keys and values into $item array like that in order to add more products to be listed:
I tried also to add in a similar way keys to $orderParams array but without success.
Either i got errors from paypal api, either the paypal listed only the first product.
$item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ',
'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item',
'L_PAYMENTREQUEST_0_AMT0' => '0.01',
'L_PAYMENTREQUEST_0_QTY0' => '1',
'L_PAYMENTREQUEST_1_NAME1' => 'Test product 1',
'L_PAYMENTREQUEST_1_DESC1' => 'Description of my next item',
'L_PAYMENTREQUEST_1_AMT1' => '0.01',
'L_PAYMENTREQUEST_1_QTY1' => '1'
);
This is my first integration, i understand the paypal flow but i can't go over this.
Thanks.
Ok, it was a simple trick to do. For those who might need it:
L_PAYMENTREQUEST_n_NAMEm - "n" is the number of transaction, 0 for 1 single transaction - "m" is the number of the product
$item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ', //title of the first product
'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item', //description of the forst product
'L_PAYMENTREQUEST_0_AMT0' => '0.01', //amount first product
'L_PAYMENTREQUEST_0_QTY0' => '1', //qty first product
'L_PAYMENTREQUEST_0_NAME1' => 'Test ', // title of the second product
'L_PAYMENTREQUEST_0_DESC1' => 'Description item',//description of the second product
'L_PAYMENTREQUEST_0_AMT1' => '0.01',//amount second product
'L_PAYMENTREQUEST_0_QTY1' => '1'//qty second product
);
$orderParams = array(
'PAYMENTREQUEST_0_PAYMENTACTION'=>'Sale', //becouse we want to sale something
'PAYMENTREQUEST_0_AMT' => '0.02', //total amount (items amount+shipping..etc)
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD', //curency code
'PAYMENTREQUEST_0_ITEMAMT' => '0.02', //total amount items, without shipping and other taxes
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0' //the shipping amount, will be 0 coz we sell digital products
);
Above you can see an example for two products.
These keys and values will be send to express checkout api in order to deliver the token.
The vars will be sent with GET.
Related
I am successfully writing invoices to Xero, including line item information, thus:
$products_list[] = array(
'Description' => $product_description,
'Quantity' => (float) $row['Quantity'],
'UnitAmount' => (float) $row['List Price'],
'DiscountRate' => $discountPercentage,
'TaxType' => 'OUTPUT2', //20% vat
'TaxAmount' => $calculatedTaxRate, //20% vat
'Name' => $xeroProductName['itemName'],
'ItemCode' => $xeroProductName['itemCode'],
'AccountCode' => $accountCode
);
All is fine except the AccountCode - no matter what I do it simply doesn't get written (neither I think does TaxAmount). I notice in Xero that 'Account' is a dropdown and when an account is selected, the tax amount is calculated.
Any help greatly appreciated.
Andy
I would like to create basically a sql statement to the effect:
Select all posts from table where post has the following assigned categories as follows: (has category==7, or has category ==8 or has category ==9) and has both categories (category ==10 and category=33) using wp-query. Note: numbers represent category ID.
I tried various wp-query category parameters.
$args = array(
'post_type' => 'post',
'category__and' => array(10,33),
'category__in' => array(7,8,9),
'order' => 'ASC',
'posts_per_page'=> '-1', // overrides posts per page in theme settings
);
Not errors just incorrect posts chosen
Thanks for your response. This worked for me
$args = array(
'post_type' => 'post',
'category__and' => array(10,33),
'cat' => 7,8,9
'order' => 'ASC',
'posts_per_page'=> '-1', // overrides posts per page in theme settings
);
I am trying to update the tracking number of an order in Bigcommerce using the API. This is the code I am using:
//update BC of order status
$filter = array('status_id' => 2);
$order_status_update = BigCommerce::updateResource('/orders/' . 105, $filter);
$order = Bigcommerce::getOrder(105);
foreach($order->products as $shipment)
{
$filter = array(
'order_address_id' => $shipment->order_address_id,
'items'=> array(
'order_product_id' => $shipment->product_id,
'quantity' => $shipment->quantity
),
'tracking_number' => 'tracking number'
);
$add_tracking = BigCommerce::createResource('/orders/105/shipments', $filter);
var_dump($add_tracking);
}
I have followed the instructions from here:
https://developer.bigcommerce.com/api/stores/v2/orders/shipments#list-shipments
BigCommerce Uploading Tracking Numbers
But I can't seem to get it to work. Can someone help?
In advance, thanks for your help!
Akshay
The payload for creating a shipment is invalid due to the items field needing to be formatted as an object array and the use of the product_id as opposed to the ID of the product within the order.
The code provided is attempting to create one shipment per product in the order, is this intended? Ideally you would ship all items in one shipment, which is why the items field is meant to be an array of product objects.
Additionally, by creating a shipment for an order the order status will automatically change to "Shipped", so the first PUT request is unnecessary.
If you were trying to create a single shipment per order and are assuming no orders will have multiple addresses then this code should work.
$order = Bigcommerce::getOrder(105);
$filter = array(
'order_address_id' => $order->shipping_addresses[0]->id,
'tracking_number' => '123456'
);
foreach($order->products as $product) {
$items[] = array(
'order_product_id' => $product->id,
'quantity' => $product->quantity
);
}
$filter['items'] => $items;
$add_tracking = BigCommerce::createResource('/orders/105/shipments', $filter);
var_dump($add_tracking);
i am trying to add product from frontend programatically following this link :
Magento: Adding new products programmatically
but i want to extend it to add custom options too to it .And i added the following code to it
$options = array();
$options[$sku] = array(
'title' => 'Option Title',
'type' => 'radio',
'is_require' => 1,
'sort_order' => 0,
'values' => array()
);
$options[$addvp['product']['sku']]['values'][] = array(
'title' => 'Option Value 1',
'price' => 0.00,
'price_type' => 'fixed',
'sku' => '',
'sort_order' => '1'
);
$options[$sku]['values'][] = array(
'title' => 'Option Value 2',
'price' => 89.00,
'price_type' => 'fixed',
'sku' => '',
'sort_order' => '1'
);
foreach($options as $sku => $option) {
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
$product = Mage::getModel('catalog/product')->load($id);
if(!$product->getOptionsReadonly()) {
$product->setProductOptions(array($option));
$product->setCanSaveCustomOptions(true);
//$product->save();
}
}
but it prints this error instead of adding custom option to product.
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`vendor`.`catalog_product_entity`, CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON DEL)
http://www.fontis.com.au/blog/magento/add-product-custom-options
Note:
The above link did what i want it to do. But one thing to be kept in mind that you must add the custom option to a product already exists/saved.
I had a similar issue. Turned out that the auto-generated SKU was somehow invalid or not properly saved on the new product I created for testing. The product was not invalid, as it did save properly on the first go, but when I revisited the product via the CMS and tried to click "save and continue" it suddenly prompted me to enter a SKU. When I re-entered the auto-generated sku it worked!
So the short answer would be: Check that your product exists by that SKU number. If it does, re-check that the SKU is being saved properly.
I need to create a new configurable product via Magento Soap API and add a related product to it.
I use this code that create 2 products ( one simple and one configur. ) then i try to link the simple one to the config one...this don't work..
There is a tutorial for do that??
Any help??
Many thanks.
// Magento login information
$mage_url = 'http://test.de/api/?wsdl';
$mage_user = 'admin';
$mage_api_key = 'admin';
// Initialize the SOAP client
$soap = new SoapClient( $mage_url );
// Login to Magento
$session = $soap->login( $mage_user, $mage_api_key );
$attributeSets = $soap->call($session,'product_attribute_set.list');
$set = current($attributeSets);
$sku = 'iphone-12345';
//configurable
$newProductData = array(
'name' => 'iPhone',
'websites' => array(1),
'short_description' => 'short description',
'description' => 'description',
'price' => 150,
'status' => '1',
'categories' => array(138),
);
$newProductRelated = array(
'name' => 'iPhone',
'websites' => array(1),
'short_description' => 'short description',
'description' => 'description',
'price' => 150,
'status' => '1',
'sku' => '2551464'
);
$productId = $soap->call($session,'product.create',array('configurable', $set['set_id'], $sku ,$newProductData));
$productId2 = $soap->call($session,'product.create',array('simple', $set['set_id'], $newProductRelated['sku'] ,$newProductRelated));
$soap->call($session, 'product_link.assign', array('configurable', $sku, $newProductRelated['sku'], array('position'=>0, 'colore'=> 21, 'qty'=>6)));
mant thx again.
Dealing with a similar issue and resorted to using the CSV import to create the relation for products imported from the API. This may may be a usable approach for a one time import via a generated CSV.