Need help with custom shipping method

I need to add custom shipping method.Carrier Packeta.com we want to use provide scrip to enable selecting pick up points.After customer select point,it returns various variable,I need one - just address of the point to send with the order.Need some simple way,maybe add to order note or if possible as extra field with shipping method,so it is able to be printed on invoice.Thank you for any help or advice.David

Here is link to this script/widget sample how it works:

[https://widget.packeta.com/v6/doc/standard-example-simple.html](https://Packeta widget sample url)

Bellow is code script we can use on website,I need that returned value of selected point is sent with the order.

<script src="https://widget.packeta.com/v6/www/js/library.js"></script>
<script>    const packetaApiKey = my-api-key...123456';
    const packetaOptions = {
        country: "cz", 
	valueFormat: "\"Packeta\",id,carrierId,carrierPickupPointId,name,city,street"
    };
    function showSelectedPickupPoint(point) {
        // Add here an action on pickup point selection
        const saveElement = document.querySelector(".packeta-selector-value");
        saveElement.innerText = '';
        if (point) {
          console.log("Selected point", point);
          saveElement.innerText = "Address: " + point.formatedValue; 
        };
    }
  </script>
<button class="packeta-selector-open" onclick="Packeta.Widget.pick(packetaApiKey, showSelectedPickupPoint, packetaOptions)">Select pick-up point<br></button>
<div class="packeta-selector-value"></div>

I just implemented something similar for our local EasyBox locker delivery service. It works very well.
I designed a very simple addon and I used hook shipping_rates.post.tpl to add the custom field and the button for locker selection popup form.
/design/themes/responsive/templates/addons/easy_box/hooks/checkout/shipping_rates.post.tpl

for javascript I used hook scripts.post.tpl
design/themes/responsive/templates/addons/easy_box/hooks/index/scripts.post.tpl

To have locker point info I added a custom profile field.
Here is the tpl:

{foreach $group.shippings as $shipping}
	{if $cart.chosen_shipping.$group_key == $shipping.shipping_id}
		{if !stristr( $all_shippings.$group_key[$shipping.shipping_id].shipping, "easybox") === FALSE}
		
			<div class="litecheckout__group" data-ca-lite-checkout-element="address-group" data-ca-address-position="shipping_first">
				<div class="litecheckout__field cm-field-container litecheckout__field--small litecheckout__field--input" data-ca-error-message-target-method="append">
					<input class="litecheckout__input" placeholder=" " id="litecheckout_s_locker_det" type="text" name="user_data[fields][{$settings.easy_box.general.easybox_field_id}]" value="" readonly = "" data-ca-lite-checkout-field="user_data.fields.{$settings.easy_box.general.easybox_field_id}" data-ca-lite-checkout-auto-save="true" autocomplete="" aria-label="locker Easybox " title="locker Easybox " data-ca-custom-validation="" onclick="easybox_init();"><br>
					<label class="litecheckout__label cm-required cm-trim" for="litecheckout_s_locker_det">locker Easybox selectat</label>
					<button title="Selecteaza" class="ty-btn ty-btn__primary" type="button" onclick="easybox_init();"> Alege EasyBox </button>
				</div>                
			</div>
		{/if}
	{/if}
{/foreach}

Thank you for sharing it,but I do not think I can work this out for myself.Probably better will be ask some codder and pay some money for it.

1 Like

You are right. This will take less than a hour for an experinced coder.

One simple way could be to add the pick-up point address as a note within the order details. This note can be easily accessible and printed on the invoice if needed. Another option, if possible, could be to create an extra field specifically for the shipping method, where the pick-up point address can be entered and stored along with other shipping details.