當前位置: 首頁>>代碼示例>>Python>>正文


Python Order.shipping_charges方法代碼示例

本文整理匯總了Python中orders.models.Order.shipping_charges方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.shipping_charges方法的具體用法?Python Order.shipping_charges怎麽用?Python Order.shipping_charges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在orders.models.Order的用法示例。


在下文中一共展示了Order.shipping_charges方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: new_order

# 需要導入模塊: from orders.models import Order [as 別名]
# 或者: from orders.models.Order import shipping_charges [as 別名]
def new_order(atg_order, tinla_profile, client):
    # Ensure that there is no profile with this atg login
    map_entry = None
    try:
        map_entry = AtgOrderMigrationMap.objects.select_related('order').get(
                        atg_order = atg_order.order.order)
        log.info("Already migrated %s, skipping new_order" % atg_order.order.order)
        return map_entry.order
    except AtgOrderMigrationMap.DoesNotExist:
        pass

    # create new order
    order = Order()
    order.user = tinla_profile
    order.state = get_order_state(atg_order.order.order_state)
    order.timestamp = atg_order.order.atg_creation_date
    order.payment_realized_on = atg_order.order.atg_submitted_date
    order.modified_on = atg_order.order.last_modified_date
    order.reference_order_id = atg_order.order.order
    order.client = client

    order.save()

    # delivery info
    shipping = DcsppShipGroup.objects.filter(order_ref = atg_order.order.order)
    if shipping: 
        shipping = shipping[0]
        dcspp_addr = DcsppShipAddr.objects.filter(shipping_group=shipping.shipping_group)
        if dcspp_addr:
            shipping = dcspp_addr[0]
            if shipping:
                addr = Address()
                addr.profile = tinla_profile
                addr.account = client.account_set.all()[0]
                addr.first_name = shipping.first_name
                addr.last_name = shipping.last_name
                addr.phone = shipping.phone_number
                addr.email = shipping.email
                addr.pincode = shipping.postal_code
                country, state, city = '', '', ''
                try:
                    if shipping.county: country = get_country(shipping.county)
                    if shipping.state and country: state = get_state(shipping.state.state_name, country)
                    if shipping.city and state: city = get_city(shipping.city, state)
                    if country: addr.country = country
                    if state: addr.state = state
                    if city: addr.city = city
                except:
                    pass

                addr.save()

                del_info = DeliveryInfo()
                del_info.address = addr
                del_info.order = order
                del_info.save()


    order_items = atg_order.order.dcspporderitem_set.all()
    list_price_total, shipping_charges = Decimal(0), Decimal(0)
    for atg_oi in order_items:
        oi = OrderItem()
        ci = atg_oi.commerce_items
        oi.order = order
        oi.state = get_order_state(ci.state)
        try:
            src = SellerRateChart.objects.get(sku=ci.sku.sku.sku_id, seller__client = client)
            oi.seller_rate_chart = src
        except SellerRateChart.DoesNotExist:
            pass

        oi.list_price = ci.amount_info.list_price
        list_price_total += ci.amount_info.list_price
        
        oi.sale_price = ci.amount_info.sale_price

        del_item = FtbShipitemRel.objects.filter(relationship__commerce_item = atg_oi)
        if del_item:
            del_item = del_item[0]
            oi.shipping_charges = del_item.shipping_cost
            shipping_charges += del_item.shipping_cost
            "shipping found for ", atg_order.order

        oi.qty = ci.quantity
        oi.save()

    # amount info
    order_discount_total = Decimal(str(atg_order.ord_misc_field1))
    sale_price_total = atg_order.order.price_info.raw_subtotal

    total_order_shipping = atg_order.order.price_info.shipping + shipping_charges
    order.shipping_charges = total_order_shipping
    order.list_price_total = list_price_total
    order.total = sale_price_total
    order.payable_amount = sale_price_total + total_order_shipping - order_discount_total
    order.save()

    print order.id
    print order.reference_order_id

#.........這裏部分代碼省略.........
開發者ID:,項目名稱:,代碼行數:103,代碼來源:


注:本文中的orders.models.Order.shipping_charges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。