Show Posts


Topics - renato.aloi

Pages: [1]
1
Support / Country selection box problem
« on: December 14, 2017, 04:17:56 PM »
Hi guys!

I am facing a strange problem with country select box in account creation form.

The above mentioned select box is appearing for me with only the last option, that is Zimbawe. Check out the image bellow...

ANNEX 1

Digging a little bit of code I found out the problem is with my language extension installation. I have installed brazilian portuguese language.

The problem is in model/localisation/country.php at line 62 through 69. For better understanding, follows the code:

--------------------------------------------------------------------
$query = $this->db->query("SELECT *, COALESCE( cd1.name,cd2.name) as name
                   FROM " . $this->db->table("countries") . " c
                   LEFT JOIN " . $this->db->table("country_descriptions") . " cd1
                      ON (c.country_id = cd1.country_id AND cd1.language_id = '" . (int)$language_id . "')
                   LEFT JOIN " . $this->db->table("country_descriptions") . " cd2
                      ON (c.country_id = cd2.country_id AND cd2.language_id = '" . (int)$default_language_id . "')
                   WHERE c.status = '1'
                   ORDER BY cd1.name,cd2.name ASC");
--------------------------------------------------------------------

In the line 67 we have a LEFT JOIN to include also country descriptions for the default language. The thing is the (int)$default_language_id is becoming 0 (zero).

So, the query results NULL for country_id field, as follows:

ANNEX 2

Any suggestions?

Thanks in advance!
Renato Aloi

2
Hi there!

I am trying to create a Hook for update method of ModelCheckoutOrder class.

$this->extensions->hk_update($this, $order_id, $order_status_id, $comment, $notify);

I have learned I must do as follows:

public function beforeModelCheckoutOrder_update() { }

I need now gain access to $order_id parameter inside my hook function. How can I do it?

Thanks in advance!

3
Development Help Needed / Checkout order update hook
« on: March 30, 2017, 04:58:11 PM »
Hi there!

I am developing a payment extension and at the end of payroll process I want to update the order status.

I was calling update function from Checkout order model, but I noticed a strange rule is in place:

$order_query = $this->db->query("SELECT *
                               FROM `" . $this->db->table("orders") . "` o
                               LEFT JOIN " . $this->db->table("languages") . " l ON (o.language_id = l.language_id)
                               WHERE o.order_id = '" . (int)$order_id . "' AND o.order_status_id > '0'");

if ($order_query->num_rows){ ...

Why is that? Why can I only update order statuses greater than '0'?

So I decided to Hook up the function adding the following code to my core extension php:

public function onModelCheckoutOrder_update()
   {
      // ...
   }

But the hook is not triggering! Any ideas?

Thank you!

Best Regards,
Renato

4
Customization help / Missing newly inserted address ID
« on: March 14, 2017, 06:03:28 PM »
Hello again!

I am stucked again at another point developing my extension.

Now I need to hook up some new fields to Address Book form.

I've managed to hook up my code in registration form when user is registering the login for 1st time. Like this:

public function onControllerPagesAccountCreate_UpdateData()
{
  $that = $this->baseObject;
  if ($that->request->is_POST())
  {
    ...
    $address_id = $result->rows[0]['address_id'];
    $that->db->query(
      sprintf("INSERT INTO `%s` (`address_id`, `address_complement`, `address_number`, `address_district`) VALUES (%d, '%s', '%s', '%s') ",
        'pse_addresses_attributes',
        $address_id,
        $request_data['complement'],
        $request_data['number'],
        $request_data['district'])
      );
  }
 ...
}

My problem now is how can I determine the $address_id when adding new address from Address Book?

At Address Book edit page there is a button called "New Address" and it triggers the insert method at ControllerPagesAccountAddress class.

For some strange reason I do not understand the method addAddress from ModelAccountAddress class (called by insert method) does not set any address_id global variable.

So how can I get the address id latter in my hook function?

I have tried this with out success:

public function onControllerPagesAccountAddress_ProcessData()
{
  $that = $this->baseObject;
  $method = $this->baseObject_method;
  $request_data = $that->request->post;

  if ($method == 'insert') $address_id = $that->db->getLastId(); // This do not work!!
  ...
}

----
P.S.: Sorry about the code off the tags, but the forum is blocking me from posting code inside apropriate tags.

The forum is gaving me this error when I try to post code inside tags:

Code: newbielink:javascript:void(0); [nonactive]

and this

Sorry, you are not allowed to post external links.
----

Thank you all in advance!

Best Regards
Renato

5
Hi there!

I am experiencing a cruel doubt on how add new language definition item...

What I am trying to do is insert new field in account create form.

Sor far I followed these steps bellow:

1) Hook up my code to create a new field into fields array then calling batchAssign, as follows:

public function onControllerPagesAccountCreate_UpdateData()
{
      $that = $this->baseObject;
      $form = new AForm();
      $form->setForm(array ('form_name' => 'AccountFrm'));
      $that->data['form']['fields']['general']['teste'] = $form->getFieldHtml(
               array (
                     'type'     => 'input',
                     'name'     => 'teste',
                     'value'    => $that->request->post['teste'],
                     'required' => true)
                  );
      $that->view->batchAssign($that->data);
      $that->processTemplate('pages/account/create.tpl');
   }

2) So far, so good. When I reloaded the create account page, the 'teste' field showed up... But for my surprise with no caption text!
>>> See image attached

3) Ok, I learned that I need to insert new language definition under System > Localization menu at Admin page, but there is a catch...

The question is: I am developing a new extension and how do I provide that new language definition at my extension's installation?

I tried to create a new xml file under extensions/myextensionname/language/english/account/create.xml as follows, but it did not work.

<?xml version="1.0"?>
<definitions>
  <definition>
    <key>entry_teste</key>
    <value><![CDATA[Teste Field:]]></value>
  </definition>
  <definition>
    <key>error_teste</key>
    <value><![CDATA[O campo Teste é obrigatório!]]></value>
  </definition>
</definitions>


Any ideas?

Thanks,
Renato

Pages: [1]

Powered by SMFPacks Social Login Mod