Giter Club home page Giter Club logo

Comments (5)

mattolson avatar mattolson commented on July 17, 2024

Can you give us a code sample along with the output? Thanks!

from bigcommerce-api-python.

filipeteles avatar filipeteles commented on July 17, 2024

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.

mattolson avatar mattolson commented on July 17, 2024

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.

filipeteles avatar filipeteles commented on July 17, 2024

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.

filipeteles avatar filipeteles commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.