Jump to content
knivbutik

Script för Skicka Lätt

Recommended Posts

Såg den här tråden och drog ihop det här i natt. Jag kör 1.5.1 och det funkar fint för mig iallafall :)

 

Steg 1.

 

Lägg in följande kod i filen /admin/themes/default/template/controllers/orders/helpers/view/view.tpl:

 

Denna la jag bredvid Ändra och Google Maps knapparna vid shipping address (bild får du välja själv ;) )

på rad 534.

<img id="skickalatt_img" src="" alt="Skicka lätt" />

 

Sen la jag in detta precis under div:en med ovanstående knappar (för mig på rad 537, alltså under diven med knapparna och ovanför adressen som skrivs ut på sidan. Dock tror jag inte att placeringen är jätteviktig.)

<div id="skickalatt" style="display: none;">
<input type="hidden" name="skl_firstname" value="{$customer->firstname}" /> <br />
<input type="hidden" name="skl_lastname" value="{$customer->lastname}" /> <br />
<input type="hidden" name="skl_email" value="{$customer->email}" /> <br />
<input type="hidden" name="skl_address1" value="{$address['address1']}" /> <br />
<input type="hidden" name="skl_address2" value="{$address['address2']}" /> <br />
<input type="hidden" name="skl_zipcode" value="{$address['postcode']}" /> <br />
<input type="hidden" name="skl_city" value="{$address['city']}" /> <br />
<input type="hidden" name="skl_cell_phone" value="{$address['phone_mobile']}" /> <br />
</div>

 

Steg 2.

 

Sen måste du ju så klart installera Greasemonkey i din webbläsare och sen installera detta script i Greasemonkey:

// ==UserScript==
// @name		  skickalatt
// @author		Björn Hansson (anpassat för Prestashop av Stefan Bergh)
// @description   Posten skicka lätt
// @include	   http://skicka.posten.se*
// @include	   http://DOMÄN.SE/ADMIN* // ÄNDRA TILL ADRESSEN TILL DIN ADMIN-KATALOG
// @require	http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
// @version   001
// ==/UserScript==
// Base url identifier of page to collect address from
var customer_info_url_base = "index.php"; // You need to change this
// When object is clicked on the above page address is collected (in this case the input field with the name firstname in the container with id customers)
var object_to_click = "#skickalatt_img";
// Attach the collect_address function to above object on the page to copy address from
if (window.location.href.indexOf(customer_info_url_base) > -1)
{
 $(object_to_click).click(collect_address);
}
else if (GM_getValue("collected") == 1 && document.location.href.indexOf("serviceSettings.aspx?ServiceKey=SkickaLatt")>-1)
{  // Posten skicka lätt page: If address is collected and we are at postens page for skicka lätt
 // Packet size
 $('#ctl00_PlaceHolderMain_ServiceSettings_SizeSettings_LengthTextBox').val('20'); // ÄNDRA OM DU VILL HA ANNAT STANDARDVAL
 $('#ctl00_PlaceHolderMain_ServiceSettings_SizeSettings_WidthTextBox').val('20'); // ÄNDRA OM DU VILL HA ANNAT STANDARDVAL
 $('#ctl00_PlaceHolderMain_ServiceSettings_SizeSettings_HeightTextBox').val('10'); // ÄNDRA OM DU VILL HA ANNAT STANDARDVAL

 // Sending company
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressCompany').val('FÖRETAGET'); // You need to change this
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressName').val(GM_getValue("fromName"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressStreet').val('ADRESS');  // You need to change this
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressZip').val('POSTNUMMER');  // You need to change this
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressCity').val('ORT');  // You need to change this
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromAddressEmail').val(GM_getValue("fromEmail"));

 // Customer info
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_fromCompany').trigger("click");
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressName').val(GM_getValue("firstname")+' '+GM_getValue("lastname"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressStreet').val(GM_getValue("address1")+' '+GM_getValue("address2"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressZip').val(GM_getValue("zipcode"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressCity').val(GM_getValue("city"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressEmail').val(GM_getValue("email"));
 $('#ctl00_PlaceHolderMain_ServiceSettings_AddressControl_toAddressMobilePhoneNumber').val(GM_getValue("cell_phone"));
}
function collect_address()
{  
 GM_setValue("firstname", $("input[name=skl_firstname]").val() );
 GM_setValue("lastname", $("input[name=skl_lastname]").val() );
 GM_setValue("email", $("input[name=skl_email]").val() );
 GM_setValue("address1", $("input[name=skl_address1]").val() );
 GM_setValue("address2", $("input[name=skl_address2]").val() );
 GM_setValue("zipcode", $("input[name=skl_zipcode]").val().replace(" ","") );   // No spaces allowed in zipcode
 GM_setValue("city", $("input[name=skl_city]").val() );	// Not actually needed since posten fills this by auto from zipcode..
 GM_setValue("cell_phone", $("input[name=skl_cell_phone]").val() );

 GM_setValue("fromName", "FÖRETAGET ELLER DITT NAMN");  // You need to change this
 GM_setValue("fromEmail", "DIN EPOST"); // You need to change this

 GM_setValue("collected", "1");

 window.open("http://skicka.posten.se/Skicka/Pages/serviceSettings.aspx?ServiceKey=SkickaLatt");
}

 

Som sagt, fungerar fint för mig men jag ger inga garantier ;)

Edited by Poffe

Share this post


Link to post
Share on other sites

Hej Poffe,

spännande, kan det fungera i PS 1.4.5.1 också?

Var hittar jag filen som ska ändras i min version?

Funkar det med Greasemonkey i Google crome också?

Använder Skicka Lätt mycket, så det skulle sitta fint.

Share this post


Link to post
Share on other sites

Tyvärr vet jag inte hur man får in det i 1.4. Jag drog igång min första prestashop för baa två veckor sedan så jag har bara använt 1.5.

Share this post


Link to post
Share on other sites

Någon som har provat om den fungerar fortfarande? Skulle behöva denna till Pacsoft.

Behöver man verkligen ändra i prestashop butikens kod? Går det inte att anpassa scriptet till de befintligt ID som finns ? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×