Inhalte aufrufen

Profilbild

newbee: address validation plugin

plugin address

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
12 Antworten zu diesem Thema

#1 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 26 February 2018 - 14:34

Hi!

 

I'm completely new to SmartStore. I need to create a plugin which validates user addresses against external APIs (i.e. cc provider)

 

Where do I start?

 

I found the code/view for the address entry, but I'd rather not make changes to the source code

 

I found the docs for plugins, but it's pretty skimpy on samples

 

so how can I intercept the saving process (from a plugin) and run some code (the validation code i have ready basically)

 

Thanks in Advance!



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 26 February 2018 - 14:53

A hook is the right way to do that. A simple example that goes in your direction is the Auditable Hook. Your hook class will look something like this:
public class AddressValidationHook : DbSaveHook<Address>....

Marcus Gesing

Smartstore AG


#3 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 26 February 2018 - 15:42

thanks! looks right.

 

Is this done as a plugin?

 

also, how will i display to the user the results of the validation? (so he can choose another/similar address)

 

thanks again!



#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 26 February 2018 - 20:44

Not in case of the auditable hook but you can use hooks in plugins as well (we've used it there several times).
 
"also, how will i display to the user the results of the validation? (so he can choose another/similar address)"
That should be done before the hook strikes. I would probably do this using jQuery/Javascript and Ajax. The code could be injected into the view via a widget.

Marcus Gesing

Smartstore AG


#5 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 04 March 2018 - 16:03

hi

thanks for your anwers

where do i find documentation for creating a widget?

i cant find anything with google

thanks again



#6 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 05 March 2018 - 09:32

I don't find anything about this in the documentation. You will find several examples in the source code.
For example here or here. When you install the Dev-Tools plugin, you get an option to display all widget zones in the shop as small labels.

Marcus Gesing

Smartstore AG


#7 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 12 March 2018 - 10:26

hi

thanks

i'm continuing with my baby-steps

i created a plugin (basically i copied an existing one, with some changes)

now i ran the packager.exe

i browse to the bin folder with the plugins dll, but the package button is disables

also read extensions does nothing

no error, no message

only the quit button is available...

please advise



#8 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 12 March 2018 - 10:47

When you copy an existing plugin you should manually change the ProjectGuid in the project file of the plugin. The root path for the Packager should be the root build web folder, not a bin folder. Actually you don't need the packager at this time. If you set the output path in plugin project corectly, the plugin is copied to ~/Plugins when compiling it, and it's available in plugin list of the backend. You can also copy the plugin folder manually to ~/Plugins and restart the application in the backend.

Marcus Gesing

Smartstore AG


#9 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 12 March 2018 - 16:09

hi

made some progress

the plugin now appears in the admin section

clicking install gives me a generic "An error occurred while updating the entries. See the inner exception for details."

no additional details

i checked the log table, nothing there either

where can i get some more info regarding the err?



#10 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 12 March 2018 - 18:29

If you don't find anything under System > Log, there are no details about the problem. I would suggest to debug your BasePlugin\IPlugin implementation of the Install method to get more details. I have never seen an error message during plugin installation.


Marcus Gesing

Smartstore AG


#11 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 12 March 2018 - 19:20

It seems that your plugin tries to alter the database. Some copy&paste leftover maybe?


Murat Cakir
SmartStore AG


#12 yisman

yisman

    Newbie

  • Members
  • Punkt
  • 7 Beiträge

Geschrieben: 14 March 2018 - 09:41

hi

how can i debug the plugin?

its installed from the dll, no?



#13 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 14 March 2018 - 11:35

Include the plugin project in the .NET solution, select "Debug" as build configuration and start the debugger.


Marcus Gesing

Smartstore AG



Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: plugin, address