ant-hq / magento-module

MIT License
0 stars 0 forks source link

Optional Shipping Address Data Causing the Sync to Fail #12

Open PivitParkour94 opened 5 years ago

PivitParkour94 commented 5 years ago

Found when syncing an order that only has a billing address attached to it, the sync dies when trying to pull in the shipping address information.

Magento shipping information is optional, if the customer selects an option to use the same information for billing and shipping, but Ant requires both, so we need to duplicate the billing info in the shipping address field if there is no specific shipping address defined.

Current request

:billing_address=>
    {:customer_id=>"135",
     :first_name=>"John",
     :last_name=>"Doe",
     :full_name=>"Doe",
     :email=>"johndoe@example.com",
     :phone=>"888-888-8888",
     :customer_company=>nil,
     :address=>
      {:address1=>"10441 Jefferson Blvd, Suite 200",
       :address2=>"",
       :suburb=>"California",
       :postcode=>"90232",
       :country=>"US"}},
   :shipping_address=>nil,

Desired Output:

:billing_address=>
    {:customer_id=>"135",
     :first_name=>"John",
     :last_name=>"Doe",
     :full_name=>"Doe",
     :email=>"johndoe@example.com",
     :phone=>"888-888-8888",
     :customer_company=>nil,
     :address=>
      {:address1=>"10441 Jefferson Blvd, Suite 200",
       :address2=>"",
       :suburb=>"California",
       :postcode=>"90232",
       :country=>"US"}},
   :shipping_address=>
    {:customer_id=>"135",
     :first_name=>"John",
     :last_name=>"Doe",
     :full_name=>"Doe",
     :email=>"johndoe@example.com",
     :phone=>"888-888-8888",
     :customer_company=>nil,
     :address=>
      {:address1=>"10441 Jefferson Blvd, Suite 200",
       :address2=>"",
       :suburb=>"California",
       :postcode=>"90232",
       :country=>"US"}},

This change should be made at ant_api/app/code/community/Ant/Api/Helper/Data.php:1708