Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- so.order_id, so.suborder_id,
- pe.sku, prodname.value as productName,
- thumbnail.value as thumbnail,
- avg(if(sb.bundle_id is null, soi.price, (1-sb.saving) * soi.price)) as price,
- soi.list_price as originalPrice,
- sum(if(sb.bundle_id is null, soi.qty, sb.qty * soi.qty)) as qty,
- ifnull(so.cod_fee, 0) as codFee,
- ifnull(so.shipping_fee, 0) as shippingFee,
- ifnull(so.giftwrap_fee, 0) as wrappingFee,
- so.discount_amount as discountAmount,
- so.tryout_discount as fpoint,
- IF(o.is_coin = 1, so.discount_amount, 0) as fhsCoin,
- CONCAT(sab.street ,' ', sab.city,' ', IFNULL(sab.region, '') ,' ', sab.country_id) AS billingAddress,
- CONCAT(sab.lastname,' ', sab.firstname) as billingName, sab.telephone AS billingPhone,
- CONCAT(sa.street ,' ', sa.city ,' ', IFNULL(sa.region, '') ,' ', IFNULL(sa.postcode, ''), ' ', sa.country_id) AS shippingAddress,
- CONCAT(sa.lastname,' ', sa.firstname) as shippingName, sa.telephone AS shippingPhone,
- so.is_sameday as isSameday
- from fahasa_suborder so
- join fahasa_suborder_item soi on so.order_id = soi.order_id and so.suborder_id = soi.suborder_id
- left join fahasa_suborder_bundle sb on soi.bundle_id = sb.bundle_id and soi.suborder_id = sb.suborder_id and soi.bundle_type = sb.bundle_type
- join fhs_catalog_product_entity pe on pe.entity_id = soi.product_id
- LEFT JOIN fhs_catalog_product_entity_varchar thumbnail ON pe.entity_id = thumbnail.entity_id AND thumbnail.attribute_id = 87
- LEFT JOIN fhs_catalog_product_entity_varchar prodname ON pe.entity_id = prodname.entity_id AND prodname.attribute_id = 71
- join fhs_sales_flat_order o on o.increment_id = so.order_id
- JOIN fhs_sales_flat_order_address sab ON o.billing_address_id = sab.entity_id
- JOIN fhs_sales_flat_order_address sa ON o.shipping_address_id = sa.entity_id
- where so.parent_id is null
- and so.suborder_id = {$suborder_id}
- group by suborder_id, pe.sku;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement