Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- class DiscountAllocations {
- constructor(){
- this.type = 'discount_code';
- this.title = 'custom discount';
- this.description = 'Reshipment';
- this.value = '10.0';
- this.value_type = 'fixed_amount';
- this.allocation_method = 'across';
- this.target_selection = 'all';
- this.target_type = 'line_item';
- this.discount_allocations = [{
- type: this.type,
- title: this.title,
- description: this.description,
- value: this.value,
- value_type: this.value_type,
- allocation_method: this.allocation_method,
- target_selection: this.target_selection,
- target_type: this.target_type
- }];
- }
- get(){
- return this.discount_allocations;
- }
- }
- class DiscountCode {
- constructor(subtotal_price){
- this.code = 'reshipment_discount';
- this.amount = subtotal_price;
- this.type = 'fixed_amount';
- this.discount_codes = [{
- code: this.code,
- amount: this.amount,
- type: this.type
- }];
- }
- get() {
- return this.discount_codes;
- }
- }
- class ShippingLines {
- constructor(line){
- this.shipping_lines = [{
- code: line[0].code,
- price: 0,
- price_set: {
- shop_money: {
- amount: line[0].price_set.shop_money.amount,
- currency_code: line[0].price_set.shop_money.currency_code
- },
- presentment_money: {
- amount: line[0].price_set.presentment_money.amount,
- currency_code: line[0].price_set.presentment_money.currency_code
- }
- },
- discounted_price: line[0].price_set.shop_money.amount,
- discount_price_set: {
- shop_money: {
- amount: line[0].price_set.shop_money.amount,
- currency_code: line[0].price_set.presentment_money.currency_code
- },
- presentment_money: {
- amount: line[0].price_set.shop_money.amount,
- currency_code: line[0].price_set.presentment_money.currency_code
- }
- },
- source: line[0].source,
- title: line[0].title,
- tax_lines: line[0].tax_lines,
- carrier_identifier: line[0].carrier_identifier,
- }];
- }
- get() {
- return this.shipping_lines;
- }
- }
- class Order {
- constructor(billing_address, buyer_accepts_marketing, currency, customer, email,
- fulfillments, fulfillment_status, line_items, note, order_id, original_order_number,
- payment_gateway_names, phone, presentment_currency, processing_method,
- refunds, reship, shipping_address, shipping_lines, subtotal_price,
- subtotal_price_set, taxes_included, total_line_items_price,
- total_line_items_price_set, total_price, total_price_set,
- total_shipping_price_set, total_weight){
- this.billing_address = billing_address;
- this.buyer_accepts_marketing = buyer_accepts_marketing;
- this.currency = currency;
- this.customer = customer;
- this.subtotal_price = subtotal_price;
- this.discount_allocations = new DiscountAllocations().get();
- this.discount_codes = new DiscountCode(subtotal_price).get();
- this.email = email;
- this.financial_status = 'paid';
- this.fulfillments = fulfillments;
- this.fulfillment_status = fulfillment_status || null;
- this.inventory_behaviour = 'decrement_obeying_policy';
- this.line_items = line_items;
- this.note = 'Reshipment issued for ' + original_order_number + ' Reason: ' + reship.reason;
- this.order_id = order_id;
- this.original_order_number = original_order_number;
- this.payment_gateway_names = payment_gateway_names;
- this.phone = phone || null;
- this.presentment_currency = presentment_currency;
- this.processing_method = processing_method;
- this.refunds = refunds;
- this.reship = {
- type: reship.type,
- reason: reship.reason
- };
- this.shipping_address = shipping_address;
- this.shipping_lines = new ShippingLines(shipping_lines).get();
- this.subtotal_price_set = subtotal_price_set;
- this.tags = 'ccapp';
- this.taxes_included = taxes_included;
- this.total_line_items_price = total_line_items_price;
- this.total_line_items_price_set = total_line_items_price_set;
- this.total_price = total_price;
- this.total_price_set = total_price_set;
- this.total_shipping_price_set = total_shipping_price_set;
- this.total_tax = 0;
- this.total_weight = total_weight;
- }
- }
- module.exports = Order;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement