Comments (5)
Can you give us a code sample along with the output? Thanks!
from bigcommerce-api-python.
Code:
import bigcommerce
api = bigcommerce.api.BigcommerceApi(host='*************.mybigcommerce.com', basic_auth=('************', '************************************************'))
productOrdersList = []
def pullOrdersProductsData():
for x in range(614530, 614539):
try:
productOrdersList.append(api.Orders.get(id="{}".format(x)).products())
except:
pass
return None
def saveToFile():
f = open("allOrderProductsData", "w", encoding='utf-8')
f.write("\n".join(map(lambda x: str(x), productOrdersList)))
f.close()
return None
pullOrdersProductsData()
saveToFile()
Output:
[<OrderProducts at 0x3e92728, {'quantity_shipped': 0, 'total_tax': '0.0000', 'wrapping_cost_tax': '0.0000', 'quantity': 1, 'parent_order_product_id': None, 'configurable_fields': [], 'cost_price_tax': '0.0000', 'fixed_shipping_cost': '0.0000', 'base_wrapping_cost': '0.0000', 'cost_price_inc_tax': '0.0000', 'base_price': '99.0000', 'wrapping_cost_inc_tax': '0.0000', 'ebay_item_id': '', 'return_id': 0, 'base_cost_price': '0.0000', 'option_set_id': 15, 'cost_price_ex_tax': '0.0000', 'event_date': '', 'price_ex_tax': '99.0000', 'name': 'University of Timbuktu Bachelor Set', 'wrapping_cost_ex_tax': '0.0000', 'order_id': 614534, 'refund_amount': '0.0000', 'total_inc_tax': '99.0000', 'id': 3, 'price_inc_tax': '99.0000', 'wrapping_name': '', 'bin_picking_number': '', 'base_total': '99.0000', 'product_id': 83, 'is_bundled_product ': False, 'sku': 'S-TIM-BAC-STD', 'total_ex_tax': '99.0000', 'is_refunded': False, 'event_name': None, 'applied_discounts': [{'amount': 99, 'id': 'total-coupon'}], 'price_tax': '0.0000', 'product_options': [{'display_style': 'Pick list', 'name': 'Bachelor gown size', 'id': 2, 'type': 'Product list', 'value': '77', 'option_id': 19, 'order_product_id': 3, 'display_name': 'Gown size', 'product_option_id': 95, 'display_value': 'Cambridge-Style Bachelor Gown, Size L'}, {'display_style': 'Pick list', 'name': 'Trencher size', 'id': 3, 'type': 'Product list', 'value': '80', 'option_id': 20, 'order_product_id': 3, 'display_name': 'Trencher size', 'product_option_id': 97, 'display_value': 'Bachelor and Masters Trencher, Size L'}], 'type': 'physical', 'order_address_id': 2, 'weight': '3.0000', 'ebay_transaction_id': '', 'wrapping_message': ''}>, <OrderProducts at 0x3e92138, {'quantity_shipped': 0, 'total_tax': '0.0000', 'wrapping_cost_tax': '0.0000', 'quantity': 1, 'parent_order_product_id': 3, 'configurable_fields': [], 'cost_price_tax': '0.0000', 'fixed_shipping_cost': '0.0000', 'base_wrapping_cost': '0.0000', 'cost_price_inc_tax': '0.0000', 'base_price': '0.0000', 'wrapping_cost_inc_tax': '0.0000', 'ebay_item_id': '', 'return_id': 0, 'base_cost_price': '0.0000', 'option_set_id': None, 'cost_price_ex_tax': '0.0000', 'event_date': '', 'price_ex_tax': '0.0000', 'name': 'Cambridge-Style Bachelor Gown, Size L', 'wrapping_cost_ex_tax': '0.0000', 'order_id': 614534, 'refund_amount': '0.0000', 'total_inc_tax': '0.0000', 'id': 4, 'price_inc_tax': '0.0000', 'wrapping_name': '', 'bin_picking_number': '', 'base_total': '0.0000', 'product_id': 80, 'is_bundled_product ': True, 'sku': 'G-CAM-BAC-L', 'total_ex_tax': '0.0000', 'is_refunded': False, 'event_name': None, 'applied_discounts': [], 'price_tax': '0.0000', 'product_options': [], 'type': 'physical', 'order_address_id': 2, 'weight': '0.0000', 'ebay_transaction_id': '', 'wrapping_message': ''}>, <OrderProducts at 0x3e92778, {'quantity_shipped': 0, 'total_tax': '0.0000', 'wrapping_cost_tax': '0.0000', 'quantity': 1, 'parent_order_product_id': 3, 'configurable_fields': [], 'cost_price_tax': '0.0000', 'fixed_shipping_cost': '0.0000', 'base_wrapping_cost': '0.0000', 'cost_price_inc_tax': '0.0000', 'base_price': '0.0000', 'wrapping_cost_inc_tax': '0.0000', 'ebay_item_id': '', 'return_id': 0, 'base_cost_price': '0.0000', 'option_set_id': None, 'cost_price_ex_tax': '0.0000', 'event_date': '', 'price_ex_tax': '0.0000', 'name': 'Bachelor and Masters Trencher, Size L', 'wrapping_cost_ex_tax': '0.0000', 'order_id': 614534, 'refund_amount': '0.0000', 'total_inc_tax': '0.0000', 'id': 5, 'price_inc_tax': '0.0000', 'wrapping_name': '', 'bin_picking_number': '', 'base_total': '0.0000', 'product_id': 87, 'is_bundled_product ': True, 'sku': 'C-STD-B&M-L', 'total_ex_tax': '0.0000', 'is_refunded': False, 'event_name': None, 'applied_discounts': [], 'price_tax': '0.0000', 'product_options': [], 'type': 'physical', 'order_address_id': 2, 'weight': '0.0000', 'ebay_transaction_id': '', 'wrapping_message': ''}>]
from bigcommerce-api-python.
This is because you are casting your OrderProducts
object to a string when writing to the file. Because we don't define __str__
See discussion here, the default implementation of casting an object to a string is used, which is what you are seeing here. You'll need to do something a little more customized to print values to a file.
from bigcommerce-api-python.
I still get the memory address, even without trying to save to a file.
Here is the code:
import bigcommerce
api = bigcommerce.api.BigcommerceApi(host='store-flx4x.mybigcommerce.com', basic_auth=('Filipe', '************************'))
productOrdersList = []
for x in range(614530, 614539):
try:
productOrdersList.append(api.Orders.get(id="{}".format(x)).products())
except:
pass
print(productOrdersList)
from bigcommerce-api-python.
Or simply if I type in the console:
a = api.Orders.get(id="614535").products()
print(a)
I will still get the memory address. Am I missing something?
from bigcommerce-api-python.
Related Issues (20)
- Zip payment method not returning in API
- Using v3 Catalog/Product filters HOT 2
- Go SDK + CloudQuery Source Plugin
- I can't get the addresses when I do an api.Customer.all()
- Rate Limit only firing once
- api.Products.count() doesn't work anymore? HOT 2
- 406 Not Acceptable ({"error":"Invalid format."}) during api.oauth_fetch_token call HOT 11
- api.ProductCustomFields.get(productidnumber,fieldidnumber).delete does not delete custom field HOT 1
- Odoo Connector
- ProductVideos cannot create, delete, or delete_all HOT 2
- Unset Price Value On Product Variations HOT 1
- Filter Keyword in API returns only exact match and not partial match
- Order field "custom_status" update returns an error HOT 2
- Seems to be no end point for Blog Tags
- 429 error shouldn't appear should it?
- Order status .iterall() infinite loop
- Updating customer password gives random 400 errors HOT 5
- Is there a way to update products in batches (more than 1 at a time)? HOT 1
- Old releases, broken functions, V3 support HOT 1
- Getting subresources alongside products (not separately) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigcommerce-api-python.