I've a problem. I'm currently writing a WordPress plugin for WooCommerce which reads out an order for a booking system.
The booking system has an own field for cod costs (costs on delivery / Nachnahmegbühr (deutsch)). The problem is that I can't find a method to read this cost from an order.
If I read out the fees from the order via $order->get_fees(), I can see the cod costs but this is not safe enough cause the fee name is always in the shop language which makes it nearly impossible to read out the cod costs this way (in an international plugin):
[data:protected] => Array
(
[order_id] => 24
[name] => Zahlungsgebühr
[tax_class] => 0
[tax_status] => taxable
[amount] => 2.16
[total] => 2.16
[total_tax] => 0.34
[taxes] => Array
(
[total] => Array
(
[6] => 0.344828
)
)
)
So is there any known way to get this kind of costs?
Related
I am currently trying to export a number of products from a custom CMS MYSQL database into a Magento compatible database.
The products include product descriptions which is stored as HTML that was serialised in a "ob_data" array with some other info when they were added through CMS system. Here is an example of one:
Array
(
[id] => 1085
[type] => 9
[url_key] => royal-worcester-mikado-milk-jug
[name] => Royal Worcester Mikado 1/2 Pint Milk Jug
[pattern] => Mikado
[manufacturer] => Royal Worcester
[stock] => 0
[content] => <p>Bone china<br />Holds approx1/2 pint.<br />Excellent condition.</p>
[weight] => 0.75
[price] => 20.00
[image] => /media/dContent/eCommerce/old/165.jpg
)
Using unserialze I can extract this and some other info into an array which can be written to the CSV. However when I write this information to a CSV file with fputcsv I get the following:
1085,9,royal-worcester-mikado-milk-jug,"Royal Worcester Mikado 1/2 Pint Milk Jug",Mikado,"Royal Worcester",0,"<p>Bone china<br />
Holds approx 1/2 pint.<br />
Excellent condition.</p>",0.75,20.00,/media/dContent/eCommerce/old/165.jpg
Essentially the <br/> tags that are in the description are also adding new lines in my CSV breaking its format and making it impossible to import.
Is there anyway that I can stop this happening and format the content so that it can comfortably written into the CSV?
I am using brain tree as a payment gateway in my website and initially I am authorizing the payment and after few minute I will submit it for settlement but its giving us following errors:
Settled amount is : 7
Total authorized amount is: [amount] => 187.50
I am getting below error:
**[_attribute:private] => amount
[_code:private] => 91551
[_message:private] => Settlement amount cannot be less than the service fee amount.**
For more details you see the response which I am getting:
Braintree_Result_Error Object
(
[success] =>
[_attributes] => Array
(
[errors] => Braintree_Error_ErrorCollection Object
(
[_errors:private] => Braintree_Error_ValidationErrorCollection Object
(
[_errors:private] => Array
(
)
[_nested:private] => Array
(
[transaction] => Braintree_Error_ValidationErrorCollection Object
(
[_errors:private] => Array
(
[0] => Braintree_Error_Validation Object
(
[_attribute:private] => amount
[_code:private] => 91551
[_message:private] => Settlement amount cannot be less than the service fee amount.
)
)
[_nested:private] => Array
(
)
[_collection:protected] => Array
(
)
)
)
[_collection:protected] => Array
(
)
)
)
[params] => Array
(
[transaction] => Array
(
[amount] => 7
)
[controller] => transactions
[action] => submit_for_settlement
[merchantId] => 6tfkyqyqnqh6ydwk
[id] => 92vsvs
)
[message] => Settlement amount cannot be less than the service fee amount.
[transaction] => Braintree_Transaction Object
So is there any time limit for submitting amount ?
Finally I got the answer of my question
The validation error you are encountering (91551 Settlement amount cannot be less than the service fee amount) for transaction 92vsvs is due to you attempting to settle the transaction for $7.00, which is below the service fee amount of $32.61 USD.
When creating a Marketplace transaction and passing a service fee, you can choose to authorize the total transaction amount initially and submit a smaller amount later on. The issue is that the service fee specified cannot be changed or lowered, so you need to submit an amount that can at least cover this service fee.
For example, transaction 92vsvs is authorized for $187.50 USD and has a service fee of $32.61 USD. At the bare minimum, you can submit $32.61 USD for settlement. You can submit any amount higher than $32.61 USD for settlement, but nothing lower. If you submitted only $32.61 USD for settlement than there would be no funds sent to the sub-merchant, since there are no funds remaining after the service fee is collected.
I have read other posts on the very same subject but I am pretty sure I have not fallen foul of the issues of those posts. This is really frustrating me now so any help or advice would be appreciated.
I am building the following array to be sent in the SetExpressCheckout call but upon each submission i get "The totals of the cart item amounts do not match order amounts " but I dont understand how!!
[METHOD] => SetExpressCheckout
[USER] => myusername
[PWD] => 1398341028
[SIGNATURE] => xxxsignaturexxx
[VERSION] => 85.0
[RETURNURL] => http://www.mysite.dev/payment/process
[CANCELURL] => http://www.mysite.dev/payment/cancelled
[PAYMENTREQUEST_0_PAYMENTACTION] => SALE
[NOSHIPPING] => 0
[PAYMENTREQUEST_0_AMT] => 189.00
[PAYMENTREQUEST_0_ITEMAMT] => 189.00
[PAYMENTREQUEST_0_TAXAMT] => 0
[PAYMENTREQUEST_0_SHIPPINGAMT] => 0
[PAYMENTREQUEST_0_HANDLINGAMT] => 0
[PAYMENTREQUEST_0_SHIPDISCAMT] => 0
[PAYMENTREQUEST_0_INSURANCEAMT] => 0
[PAYMENTREQUEST_0_CURRENCYCODE] => GBP
[LOCALECODE] => GB
[ALLOWNOTE] => 1
[L_PAYMENTREQUEST_0_NAME0] => Website Order
[L_PAYMENTREQUEST_0_NUMBER0] => 28424747
[L_PAYMENTREQUEST_0_AMT0] => 189.00
[L_PAYMENTREQUEST_0_QTY0] => 1
Many Thanks for reading.
Kris
I went ahead and tested your call using a test account and initially it gave a similar error to what you described. I did get it to work with the only modifications I made being the format and spacing of the call.
This is the call I submitted and got a successful response, note I did have to change the user, pwd, signature, version, returnrul, and cancelurl to be able to test it:
USER=chad_1311276857_biz_api1.x.com
PWD=NGAEWP367NNSDXP2
SIGNATURE=Aef0iZ4csmtdchFhBLFKNKS88OSVA0f08rNWMEUk1J-tsdbDOFq0JpNi
METHOD=SetExpressCheckout
VERSION=113.0
RETURNURL=http://ccaples.com/index.php/api-s/paypal-nvp/nvp-quick-test
CANCELURL=http://ccaples.com/index.php/api-s/paypal-nvp/nvp-quick-test
PAYMENTREQUEST_0_PAYMENTACTION=SALE
NOSHIPPING=0
PAYMENTREQUEST_0_AMT=189.00
PAYMENTREQUEST_0_ITEMAMT=189.00
PAYMENTREQUEST_0_TAXAMT=0
PAYMENTREQUEST_0_SHIPPINGAMT=0
PAYMENTREQUEST_0_HANDLINGAMT=0
PAYMENTREQUEST_0_SHIPDISCAMT=0
PAYMENTREQUEST_0_INSURANCEAMT=0
PAYMENTREQUEST_0_CURRENCYCODE=GBP
LOCALECODE=GB
ALLOWNOTE=1
L_PAYMENTREQUEST_0_NAME0=Website Order
L_PAYMENTREQUEST_0_NUMBER0=28424747
L_PAYMENTREQUEST_0_AMT0=189.00
L_PAYMENTREQUEST_0_QTY0=1
When I send a request with FEDEX_GROUND, I get this error. Is there a workaround to switch out the shipping method without explicitly looking for this error and retrying the request?
Array
(
[HighestSeverity] => ERROR
[Notifications] => Array
(
[0] => Array
(
[Severity] => ERROR
[Source] => crs
[Code] => 924
[Message] => This shipment qualifies for FedEx Home Delivery. Please resubmit your request with serviceType Ground Home Delivery.
[LocalizedMessage] => This shipment qualifies for FedEx Home Delivery. Please resubmit your request with serviceType Ground Home Delivery.
)
[1] => Array
(
[Severity] => WARNING
[Source] => crs
[Code] => 304
[Message] => Requested shipment package count did not match the summed total of group package count values; the summed total of group package count values was used to rate.
[LocalizedMessage] => Requested shipment package count did not match the summed total of group package count values; the summed total of group package count values was used to rate.
)
)
[Version] => Array
(
[ServiceId] => crs
[Major] => 10
[Intermediate] => 0
[Minor] => 0
)
)
Before you perform the label request, if the service = Ground and res=True then you should switch the service over to Ground Home Delivery. This will resolve the error.
I already had this error when the PackageCount wasn't representing the number of RequestedPackageLineItems.
<ns1:PackageCount>2</ns1:PackageCount>
<ns1:RequestedPackageLineItems><...>
<ns1:RequestedPackageLineItems><...>
If you have 2 RequestedPackageLineItems, set your PackageCount to two.
I have defined some custom attributes and assigned them to products via the Opencart admin panel. I'm trying to retrieve these attributes upon checkout to adjust some shipping costs.
I'm currently working in the catalog/model/shipping/ups.php file in the getQuote function. I'm getting close with this:
print_r($this->cart->getProducts());
Which gives me the following product data:
Array
(
[59] => Array
(
[key] => 59
[product_id] => 59
[name] => My Product Name
[model] => ABC
[shipping] => 1
[image] => data/myproduct.jpg
[option] => Array
(
)
[download] => Array
(
)
[quantity] => 1
[minimum] => 1
[subtract] => 1
[stock] => 1
[price] => 29.99
[total] => 29.99
[reward] => 0
[points] => 0
[tax_class_id] => 0
[weight] => 3.75
[weight_class_id] => 5
[length] => 0.00
[width] => 0.00
[height] => 0.00
[length_class_id] => 3
)
)
However, no custom attributes are returned. I'm sure there is a nice way to pass the product ID to an attribute-getting function, but I can't find it. The Opencart docs are a little lacking for the development side and no luck on Google.
Usually I'd grep the hell out of the whole directory structure to find what I'm looking for, but shell access is disabled on this particular web host :(.
EDIT
I believe Attributes are a newer feature that is built into Opencart. Its like a custom field.
Anyway, on the admin side I went to Catalog > Attributes and created a custom attribute called "Shipping Box Type". Then, under a specific product I can set the attribute. See screenshot. My goal is to retrieve the value of "Shipping Box Type". Does that answer your question #Cleverbot? I'm sure I can do a custom db query to grab it, but theres got to be a built-in function to grab attributes?
Retrieve attributes for a given product_id
$this->load->model('catalog/product');
$attributes = $this->model_catalog_product->getProductAttributes(59);
print_r($attributes);
Output
Array
(
[0] => Array
(
[attribute_group_id] => 9
[name] => Shipping Fields
[attribute] => Array
(
[0] => Array
(
[attribute_id] => 16
[name] => Shipping Box Type
[text] => SM2
)
)
)
)
Taking it further, here is an example of looping through the products currently in the cart to see what attributes they have:
$this->load->model('catalog/product');
$cart_products = $this->cart->getProducts();
// get attributes for each product in the cart
foreach($cart_products as $product) {
$attributes = $this->model_catalog_product->getProductAttributes($product['product_id']);
print_r($attributes);
}
This is not the most intuitive feature in Opencart. First you have to go catalog>attributes>attribute groups and you have to create a group name that will be a title for your attribute. For this it might be "Shipping Specifications".
Then you need to go to catalog>attributes>attributes> and create a new attribute under "Shipping Specifications" named "Shipping Box Type".
Now you are ready to go to catalog>products and add the attribute to a product.
The catch is that it won't be displayed how you were hoping I think. It will show up under the specifications tab next to description on your products page. You have the easy option of changing "Specifications" to the Heading of your choice in catalog/view/*your_theme*/products/products.tpl or you can edit the same tpl file to change the container/format that the data output goes.