Jump to content
WebFlake
  • 0

IP.Nexus Custom Actions Help


Tutu

Question

Long story short, I want IP.Nexus to run a certain php script after anyone completes their purchase.

I already know HOW to do so, I'd just like a better understanding of what data is actually posted to the provided page.

/**
     * Item Purchased (run before onPurchaseGenerated)
     *
     * @param	array	The member purchasing
     * @param	array   Package data (combined array with row from nexus_packages and nexus_packages_*, depending on the package type)
     * @param	invoice	Invoice Model
     * @return	void
     */
    public function onPaid( $member, $package, $invoice )
    {
        
    }

How does IP.Nexus post the package(s)? I know it posts an array with the package settings (or atleast I think), though how would I go about properly retreiving data? Also, how would I go about retreiving any data if someone purchased more than one package?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Since IPS never tells you anything , you have to use display techniques to get the information it passes.

 

So for information purposes add tis to the code and it will create a file with the input data. Something like this

 $file = fopen("/cache/IP_Nexus.cgi","a");
 fputs($file,"n Member n".print_r($member,true)."n");
 fputs($file,"n Package n".print_r($package,true)."n");
 fputs($file,"n Invoice n".print_r($invoice,true)."n");
 fclose($file);

This assumes the forum is in the root (public_html) folder. If in a folder called forum then this "/cache/IP_Nexus.cgi" should be "/forum/cache/IP_Nexus.cgi"  

Edited by Lock Down
Link to comment
Share on other sites

  • 0

How do I count how many packages were purchased?

I know I can call package data like so,

 

public function onPaid( $member, $package, $invoice )
{

   

    $package_name =$package['p_name']; //EXAMPLE
}

 

but how would I count packages in multiple were purchased, and retreive data from each one?

Link to comment
Share on other sites

  • 0

Logged my invoice, because my $package parameter only contains one item,

invoice Object
(
    [data:invoice:private] => Array
        (
            [i_status] => pend
            [i_title] => BETA Tag
            [i_member] => 1
            [i_items] => Array
                (
                    [0] => Array
                        (
                            [act] => new
                            [app] => nexus
                            [type] => product
                            [cost] => 0
                            [tax] => 0
                            [renew_term] => 0
                            [renew_units] => 
                            [renew_cost] => 0
                            [quantity] => 1
                            [physical] => 
                            [shipping] => Array
                                (
                                )

                            [subscription] => 
                            [weight] => 0
                            [itemName] => BETA Tag
                            [itemID] => 8
                            [cfields] => Array
                                (
                                )

                            [opt_id] => 0
                            [groupRenewals] => 0
                            [methods] => Array
                                (
                                )

                            [_tax] => 0
                        )

                )

            [i_total] => 0
            [i_date] => 1387345380
            [i_return_uri] => 
            [i_paid] => 0
            [i_status_extra] => a:1:{s:4:"type";s:4:"zero";}
            [i_discount] => 0
            [i_temp] => 
            [i_ordersteps] => 0
            [i_noreminder] => 1
            [i_renewal_ids] => Array
                (
                )

            [i_po] => 
            [i_notes] => 
            [i_shipaddress] => 
            [i_id] => 159
        )

With the provided, I can use a for loop like so,

for ($i=0; $i<$invoice['quantity']; $i++) {

  //LOOP_FOR_EACH_ITEM

}

but how do I get data from EACH package?

 

Like I stated, $package['...'] only contains data for the first item in the invoice.

I also tried using a multi-dimensional array, but no luck,

 

IE;

$package['p_name'][0]

Here's a package array with TWO items


 Package 
Array
(
    [p_id] => 9
    [p_name] => ALPHA Tag
    [p_seo_name] => alpha-tag
    [p_desc] => This is a test package
    [p_exp_days] => 
    [p_group] => 1
    [p_stock] => -1
    [p_reg] => 0
    [p_store] => 1
    [p_member_groups] => *
    [p_allow_upgrading] => 0
    [p_upgrade_charge] => 0
    [p_allow_downgrading] => 0
    [p_downgrade_refund] => 0
    [p_base_price] => 0.00
    [p_tax] => 0
    [p_renew_options] => a:0:{}
    [p_renewal_days] => 0
    [p_primary_group] => 0
    [p_secondary_group] => 
    [p_perm_set] => 
    [p_return_primary] => 1
    [p_return_secondary] => 1
    [p_return_perm] => 1
    [p_module] => subscribe
    [p_position] => 9
    [p_associable] => 
    [p_force_assoc] => 0
    [p_assoc_error] => 
    [p_discounts] => a:3:{s:7:"loyalty";a:0:{}s:6:"bundle";a:0:{}s:9:"usergroup";a:0:{}}
    [p_page] => 0
    [p_support] => 0
    [p_support_department] => 1
    [p_support_severity] => 0
    [p_featured] => 0
    [p_upsell] => 0
    [p_notify] => 
    [p_type] => product
    [p_custom] => 0
    [p_reviewable] => 1
    [p_review_moderate] => 0
    [p_image] => 
    [p_methods] => 
    [p_group_renewals] => 0
    [p_rebuild_thumb] => 0
    [id] => 9
    [p_physical] => 0
    [p_subscription] => 0
    [p_shipping] => 
    [p_weight] => 0
    [p_lkey] => 0
    [p_lkey_identifier] => 0
    [p_lkey_uses] => 0
    [p_locations] => 
    [p_exempt] => 
    [p_expire] => 
    [p_expire_unit] => 
    [p_max_height] => 
    [p_max_width] => 
    [p_queue] => 
    [p_quota] => 
    [p_ip] => 
    [p_cgi] => 
    [p_frontpage] => 
    [p_hasshell] => 
    [p_maxftp] => 
    [p_maxsql] => 
    [p_maxpop] => 
    [p_maxlst] => 
    [p_maxsub] => 
    [p_maxpark] => 
    [p_maxaddon] => 
    [p_bwlimit] => 
)

It only displays data for ONE package, as already stated.

Link to comment
Share on other sites

  • 0

Yes, the log only displayed ONE array including one package.

I have two packages set up; Alpha & Beta, only one of them is logged when I make a transaction (last one in my cart).


Alright, I THINK I understand what to do now, I just need some help actually getting data,


 Invoice 
invoice Object
(
    [data:invoice:private] => Array
        (
            [i_status] => pend
            [i_title] => BETA Tag, ALPHA Tag
            [i_member] => 1
            [i_items] => Array
                (
                    [0] => Array
                        (
                            [act] => new
                            [app] => nexus
                            [type] => product
                            [cost] => 0
                            [tax] => 0
                            [renew_term] => 0
                            [renew_units] => 
                            [renew_cost] => 0
                            [quantity] => 1
                            [physical] => 
                            [shipping] => Array
                                (
                                )

                            [subscription] => 
                            [weight] => 0
                            [itemName] => BETA Tag
                            [itemID] => 8
                            [cfields] => Array
                                (
                                )

                            [opt_id] => 0
                            [groupRenewals] => 0
                            [methods] => Array
                                (
                                )

                            [_tax] => 0
                        )

                    [1] => Array
                        (
                            [act] => new
                            [app] => nexus
                            [type] => product
                            [cost] => 0
                            [tax] => 0
                            [renew_term] => 0
                            [renew_units] => 
                            [renew_cost] => 0
                            [quantity] => 1
                            [physical] => 
                            [shipping] => Array
                                (
                                )

                            [subscription] => 
                            [weight] => 0
                            [itemName] => ALPHA Tag
                            [itemID] => 9
                            [cfields] => Array
                                (
                                )

                            [opt_id] => 0
                            [groupRenewals] => 0
                            [methods] => Array
                                (
                                )

                            [_tax] => 0
                        )

                )

            [i_total] => 0
            [i_date] => 1387402379
            [i_return_uri] => 
            [i_paid] => 0
            [i_status_extra] => a:1:{s:4:"type";s:4:"zero";}
            [i_discount] => 0
            [i_temp] => 
            [i_ordersteps] => 0
            [i_noreminder] => 1
            [i_renewal_ids] => Array
                (
                )

            [i_po] => 
            [i_notes] => 
            [i_shipaddress] => 
            [i_id] => 170
        )

    [customer] => customer Object
        (
            [data] => Array
                (
                    ...
                )

            [cardhandler:customer:private] => 
        )

    [takeAction] => 1
)


That's my invoice array with two items, I'd just like to know how to properly grab data from the sub array '[i_items]'.

The following doesn't work,

$invoice['i_items'][0]['itemName']

Though, assuming I do use the invoice array to grab my item data, I still can't access a custom data-field I implemented into the package table in the db.


UPDATE:

 

Figured out why I CAN'T access invoice data, it's a private field.

Which means I NEED to use the package array, but it's only returning ONE package..


UPDATE:

 

Turns out my Nexus I had installed was nulled/bugged.. Installed clean and the arrays are being posted as they should.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...