Magento Expert Forum - Improve your Magento experience

Results 1 to 7 of 7

How to recieve custom data from frontend to shipping method on checkout

  1. #1
    New member
    Join Date
    Jun 2018
    Location
    Russia, Moscow
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to recieve custom data from frontend to shipping method on checkout

    Hello everyone!



    How can i recieve custom data (array or json) from frontend to custom shipping method? On frontend, when I check shipping method, I have map with select delivery point option. When I need to recieve selected point data to my shipping method. How can I do that?

    I was create observable object in quote object (quote.pickPoint) and set point data to it. But I can not add this data to payload and get it in CollectRates method in my shipping method.

    Please help anyone! Thanks beforehand.



    My code:

    /js/view/shipping.js:

    Code:
    return Component.extend({
            ...        
            pickPoint: ko.observable(false)
    }
    /js/view/modal.js (show modal with pickpoints map)

    Code:
    window.onPointSelected = function (data) {
       ...
       //Data ricieved from shipping carrier
       var pointData = {
          city: data['city'],
          region: data['region'],
          address: data['address'],
          deliveryCost1: data['deliveryCost1'],
          deliveryCost2: data['deliveryCost2'],
          deliveryCost3: data['deliveryCost3'],
          deliveryCost4: data['deliveryCost4'],
          deliveryCost5: data['deliveryCost5'],
          deliveryCost6: data['deliveryCost6'],
          deliveryCost7: data['deliveryCost7'],
          deliveryCost8: data['deliveryCost8'],
          hash: data['hash'],
          hash8: data['hash8'],
          hash16: data['hash16'],
          name: data['name'],
          returnCost1: data['returnCost1'],
          returnCost2: data['returnCost2'],
          returnCost3: data['returnCost3'],
          returnCost4: data['returnCost4'],
          returnCost5: data['returnCost5'],
          returnCost6: data['returnCost6'],
          returnCost7: data['returnCost7'],
          returnCost8: data['returnCost8'],
          shopId: data['shopId'],
          deliveryOperatorId: data['deliveryOperatorId'],
          deliveryOperator: data['deliveryOperator']
    };
    
    quote.pickPoint(pointData);
    
    //Trigger hack for rates reload:
    
    var address = quote.shippingAddress();
    rateRegistry.set(address.getKey(), null);
    rateRegistry.set(address.getCacheKey(), null);
    quote.shippingAddress(address);
    Then I add pickPont data to payload /js/model/shipping-save-processor/default.js

    Code:
    return {
        saveShippingInformation: function () {
        ...
            payload = {
                 addressInformation: {
                    shipping_address: quote.shippingAddress(),
                    billing_address: quote.billingAddress(),
                    shipping_method_code: quote.shippingMethod().method_code,                        
                    shipping_carrier_code: quote.shippingMethod().carrier_code
                 },
                    pickPoint: quote.pickPoint()
                 };
    
           fullScreenLoader.startLoader();
    Now, how can I get pickPoint data from collectRates method of the my custom shipping carrier? This data I need for shipping cost calculation and set pickPoint address to shipping address.

    Thanks!

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    Jun 2018
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for sharing with us

  3. #3
    New member
    Join Date
    Jun 2018
    Location
    Russia, Moscow
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your answer! I need help with it, i have no idea about recieve custom data to shipping method. I try to use file_get_content(php://input) — I know its ugly method, but with it

    $method->setPrice($amount);
    $method->setCost($amount);

    Not working, shipping cost set to 0, although $amount sets correctly in collectRates method.

  4. #4
    New member
    Join Date
    Jun 2018
    Location
    Russia, Moscow
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please help anyone, I working with problem whole days without any results.
    Maybe any ideas?

  5. #5
    New member
    Join Date
    Jun 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Couponstechie

    As always found nice content related to the important issue. lorextechnology Coupons could deduct an amount of your bill on purchasing of lorex security cameras.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    156
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Instructions to conceal a few fields in One Step Checkout shipping address; 4. Instructions to present extra information to the spot request work; 5. The most effective method to All Model-View of the UI Component is written in view/frontend/web/js/see and the layout perspective on UI Component is written in payment.html: get the installment list.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •