News:

AbanteCart v1.4.2.1 is released.

Main Menu

Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

Working on custom extension

Started by vitalmyth, September 11, 2013, 08:42:07 PM

Previous topic - Next topic

vitalmyth

First, thank you to the Abante team, because I love this cart and I think it is very well made. I am trying to build a very simple custom extension for my business. I am new to web development, but I have done this same extension project for other, simpler carts, and I am trying to figure out how to do the same thing for Abante.

I have several questions, but I will ask them one at a time. First let me introduce the project.

The idea is very simple:
- When customer confirms an order, extension will send order data to a third-party API. Nothing is visible on storefront, but data is sent at checkout/success
- API will return 2 responses. Now I need to store the responses somewhere with order_id, so that I can select them by order_id later. For example, in a new table called "vitalmyth_notes", which has 3 columns: order_id (same as orders table), vitalmyth_response_1, vitalmyth_response_2.
- On admin backend, the page at sales/orders/order #X now shows 2 new things in "Order Summary" section. These new things are vitalmyth_response_1 and vitalmyth_response_2.
- vitalmyth_response_2 will change after first creation. When the order is first confirmed, it will be "Wait," and then after 1-5 days, "Done." So on admin/orders/order #X, I need something like this (very simplified):

$current_response_2 = select vitalmyth_response_2 from table vitalmyth_notes where order_id = id_of_order_X;
if ($current_response_2 == 'Wait') {
$postfields = select * from table_orders where order_id = id_of_order_X;
$response = curl_exec($postfields);
$this->db->execute(update table vitalmyth_notes set vitalmyth_response_2=$response where order_id = id_of_order_X);
echo $vitalmyth_response_2;
} else { echo $vitalmyth_response_2; }

I hope that makes sense although it is not actual code.

My first question is...my extension will be dependent upon ANY credit card gateway, not just 1 in particular. So if ANY credit card gateway is installed, my extension will work, but will not work for other types of orders (cod, bank transfer, etc). Can I set dependencies so that at least 1 credit card gateway is required, but it can be any gateway?

abolabo

Yes. You can set dependencies inside file config.xml of your extension.
for ex:
<dependencies>
       <item prior_version="0.9" version="1.0.1">your_payment_gateway_extension_text_id</item>
       <item prior_version="0.9" version="1.0.1" required="true">your_payment_gateway_extension_text_id</item>
</dependencies>

and then go to your's extension edit page in admin and you will see that dependants there.

vitalmyth

#2
edit: oops, post made no sense after i changed some things. fixed now.

Thank you. What if I have required="true" for multiple extensions? This means (your_payment_gateway_extension && another_payment_gateway_extension && another2_payment_gateway_extension) ALL are required, right?

what if I need (your_payment_gateway_extension || another_payment_gateway_extension || another2_payment_gateway_extension), ANY required?

maybe I need to check for this in my own code, like:

(sorry, I cannot put in code tags below, getting error "You cannot post external links" when using [ code ] tags)

$vital_myth_compatible_extensions = array('paymentgateway1' => 'authorizeaim', 'paymentgateway2' => 'paypal_pro', 'paymentgateway3' => 'secure_checkout');
$enabled_extensions = array( ...all of the extensions enabled right now... );
foreach ($enabled_extenstions as $extension) {
if (in_array($extension, $vitalmyth_compatible_gateways)) {
$compatible = true; }
} if ($compatible) { ---my code stuff--- } else { error('No credit card payment gateway enabled'); }

vitalmyth

New question. I am new to hooks so I am not sure how to use them. Assume I make my extension dependent on default_authorizeaim_net. I want to add note "Hello" to admin order page after the default_authorizeaim_net notes. They look like:

QuoteAuthorization Code: 000000
AVS Response: P
Transaction ID: 0
Card Code Response: 252C77980EAA158C200EAC622BAF5F10
Cardholder Authentication Verification Response:

So I want to do this:
QuoteAuthorization Code: 000000
AVS Response: P
Transaction ID: 0
Card Code Response: 252C77980EAA158C200EAC622BAF5F10
Cardholder Authentication Verification Response:
Hello

Will this work?

Quote
class Vitalmyth extends Extension {
public function afterDefaultAuthorizeNetAimsend() {
$this->model_checkout_order->update($this->session->data['order_id'], 1, 'Hello', FALSE);
}
}

Forum Rules Code of conduct
AbanteCart.com 2010 -