SilverCart Forum

We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?

You can help us helping you by providing detailed error messages, screenshots and logfile entries.

SebastianRamon

Page: 1 , 2 , 3 , 4
Topic Change fields in an Address 8416 Views

Re: Change fields in an Address

8 November 2013 at 5:09pm

Actually, I commented out "extendedProcess()" in the decorator, as it did not help to include State in the overview page.

Removing the comment and testing it again gives this notice message:
"[Notice] Undefined property: SilvercartCheckoutFormStepProcessOrderXtension::$controller"

Before adding "loadAdditionalCheckoutData()" I did not have this issue.

My extendedProcess() method is a copy of Sascha's, I just copied the whole method, and added two lines:

....
$shippingData = SilvercartTools::extractAddressDataFrom('Shipping', $checkoutData);
$invoiceData = SilvercartTools::extractAddressDataFrom('Invoice', $checkoutData);
$shippingData['State'] = $checkoutData['Shipping_State'];
$invoiceData['State'] = $checkoutData['Invoice_State'];
....

So, I "dunno"...

best
Szabesz

Re: Change fields in an Address

8 November 2013 at 6:14pm

Try to replace $this->controller with $this->owner->Controller().

Cheers
Sebastian

Re: Change fields in an Address

9 November 2013 at 11:23am Last edited: 9 November 2013 11:24am

Oh, bummer! Thanx again! Sometimes I just forget that we need "owner" to get the proper reference...

And regarding the custom filed problem, I decided not to use one! After working on it for hours, I still found to more classes I should deal with: SilvercartCheckoutFormStep2Anonymous and SilvercartCheckoutFormStep2Regular. Actually, the step that leaves my custom State filed behind is Step 2.

Since "joinAddressDataTo" for regular customers and submit/submitSuccess for Anonymous customers both use hard coded routines to process the address fields, I decided to "recycle" the built in fields instead of trying to and a new one.

As "Addition" is VarChar(255), now I use it as a State field (it is long enough) and I chose StreetNumber for the apartment number, which is VarChar(15), long enough to store a short code.

But thanx anyway for your kind help! Now I have my forms and templates customized the way I need and everything seems to work fine :)

Best regard,
Szabesz

p.s.: In the future, maybe you should consider refactoring this part of SilverCart, so that adding a new field to the address is not so complicated. Dealing with fields with this hard coded manner should be eliminated.

Re: Change fields in an Address

16 November 2013 at 2:57pm

Hi,

Just a follow up on this. Actually, using Addition instead of a dedicated State field did not turn out to be a good idea, as the PayPal module works with State, so it is really needed in case of a US PayPal setup.

So, in order to get the decorated State field get through, I simply added State to the following classes:
silvercart/code/pages/SilvercartCheckoutStep.php
silvercart/code/custom_forms/checkout/SilvercartCheckoutFormStep2Anonymous.php
silvercart/code/base/SilvercartTools.php
silvercart/code/base/SilvercartPaymentMethod.php

These are the classes where State seems to be needed. With this hack and the previously discussed decorators and changes, PayPal transactions are accepted. So these modifications seem to do the trick.

best
Szabesz