I'm using drupal(7.38), civicrm(4.6.5), ubercart(7.x-3.8) and ubercart_civicrm(7.x-4.x-dev). Whenever a user(registered/anonymous) is purchase a product from the site, a contribution will be added into the civcrm user. If the user is anonymous, system will create the user by using email both in drupal as well as civicrm also. I notice some of the products status is 'Abandoned' in ubercart, but under the corresponding user contribution tab, the product is listing as Completed. I gone throw the uc_civicrm module at last I found some piece of codes in uc_civicrm/uc_civicrm.module
function _uc_civicrm_map_contribution_status($order_status) {
// NOTE: There may be a more "correct" way to do this.
$map = array(
"completed" => 1,
"payment_received" => 1,
"pending" => 2,
"processing" => 5,
"canceled" => 3,
"in_checkout" => 5,
);
if (array_key_exists($order_status, $map)) {
$id = $map[$order_status];
}
else {
// Oh no.
$id = 1;
watchdog('uc_civicrm', 'There is no status that maps to %order_status, marking as "Complete"', array('%order_status' => $order_status), WATCHDOG_WARNING);
}
return $id;
}
I want to synchronize ubercart order status with civicrm contributions status. Please help me out this. Thanks in advance
If you want to map 'abandoned' to the 'canceled' status in CiviCRM (there is no "abandoned" status in CiviCRM) you could revise the above like so:
$map = array(
"completed" => 1,
"payment_received" => 1,
"pending" => 2,
"processing" => 5,
"canceled" => 3,
"abandoned" => 3,
"in_checkout" => 5,
);
Then I'd recommend making a bug report/patch on the issue you filed at the project page so it gets into the module core if the maintainers agree.
On the one site where we had CiviCRM and Ubercart well (it was Drupal 6) we ended up needing to use both
- UC CiviCRM,
- Ubercart CiviCRM Products
but I see the latter only was released for D6
More recently for Commerce integration we have switched from using the module to using CiviCRM Entity and Drupal Rules.
Not sure how much the above helps but thought I should mention it.
Related
I have an Auth process which works fine with one userModel. But not only because of my DB schema I need to have one login method/action which works with multiple models.
So far I've tried everything I was able to think of or find online - for example editing this Cake 1.3 solution into Cake 3 and a few more hints I was able to find.
However, I'm not able to figure it out.
Thank you for any answer.
My AppController component load:
$this->loadComponent('ExtendedAuth', [
'authenticate' => [
'Form' => [
//'userModel' => 'Admins',
'fields' => [
'username' => 'email',
'password' => 'password'
]
]
],
'loginAction' => [
'controller' => 'Admins',
'action' => 'login'
],
// If unauthorized, return them to page they were just on
'unauthorizedRedirect' => $this->referer(),
]);
My ExtendedAuthComponent:
class ExtendedAuthComponent extends AuthComponent
{
function identify($user = null, $conditions = null) {
$models = array('Admins', 'Users');
foreach ($models as $model) {
//$this->userModel = $model; // switch model
parent::setConfig('authenticate', [
AuthComponent::ALL => [
'userModel' => $model
]
]);
$result = parent::identify(); // let cake do its thing
if ($result) {
return $result; // login success
}
}
return null; // login failure
}
}
EDIT1: Description of situation
I have two separate tables (Admins, Users). I need just one login action which tries to use Admins table prior to Users. Because of the application logic I can't combine them to one table with something like 'is_admin' flag. So basically what I need is instead of one specific userModel set in Auth config, I need a set of models. Sounds simple and yet I'm not able to achieve it.
EDIT2: Chosen solution
Based on the answer below, I decided to update my schema. Auth users table is just simplified table with login credentials and role and other role-specific fields are then in separate tables which are used as a connection for other role-specific tables. Even though the answer is not exactly a solution for the asked question, it made me think more about any possible changes of the schema and I found this solution because of it so I'm marking it as a solution. I appreciate all comments as well.
As Mark already said in a comment: Don't use two users tables. Add a type field or role or whatever else and associated data in separate tables if it's different like admin_profiles and user_profiles.
Don't extend the Auth component. I wouldn't recommend to use it anymore any way because it's going to get deprecated in the upcoming 3.7 / 4.0 release. Use the new official authentication and authorization plugins instead.
If you insist on the rocky path and want to make your life harder, well go for it but then you should still not extend the auth component but instead write a custom authentication adapter. This is the right place to implement your custom 2-table-weirdness. Read this section of the manual on how to do it.
Please forgive my English in future updates.
I am experiencing problems mongodb php $nin query.
I can get a list of friend requests, but I can't get a list of 'not friends'.
sql:Select * from uyeler where id NOT IN (select kime from ark where kim=$userid)
Friends request users:
$uu = $ark->find(array('kim' => 0),array("kime" => 1,"_id"=>0)); // works
NOT friends request
$aa = $uyeler->find(array('id' => array('$nin' => array($uu)))); /// Doesn't work - shows same $uu (all friends, answer 1, 2, 3...)
Please have a look at look at:
and
and my code
I'm looking for a way to create an organic group in code.
On the web i find manny resources on how to add a node to a group etc, but not how to create a group itself.
I have done it using the drupal interface, but this isn't very portable. I have tried using the features module, although i found that had to many issues. Missing fields etc.
Through the interface you create a group by making a new contenttype, and then under the tab 'organic groups' you select 'group'
I know how to create a content type in code
$type = array(
'type' => 'Termbase2type',
'name' => t('Termbase2name'),
'base' => 'node_content',
'custom' => 1,
'modified' => 1,
'locked' => 0,
'title_label' => 'Termbase2',
'description' => 's a database consisting of concept-oriented terminological entries (or ‘concepts’) and related information, usually in multilingual format. Entries may include any of the following additional information: a definition; source or context of the term; subject area, domain, or industry; grammatical information (verb, noun, etc.); notes; usage label (figurative, American English, formal, etc.); author (‘created by’), creation/modification date (‘created/modified at’); verification status (‘verified’ or ‘approved’ terms), and an ID. A termbase allows for the systematic management of approved or verified terms and is a powerful tool for promoting consistency in terminology. *wiki',
'og_group_type' => 1,
'og_private' => 0,
'og_register' => 0,
'og_directory' => 0,
'og_selective' => 3,
);
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
but i can't find any clue as to how to set the content type as a group, so it can have group members.
This worked:
// get existing content types
$content_types = node_type_get_types();
$t = get_t();
// create the currency CT
$type_name = 'cc';
if (!array_key_exists($type_name, $content_types)) {
// Create the type definition array.
$type = array(
'type' => $type_name,
'name' => $t('Community Currency'),
'base' => 'node_content',
'description' => $t('A community that trades in a virtual currency.'),
'custom' => 1,
'modified' => 1,
'locked' => 0,
);
$type = node_type_set_defaults($type);
node_type_save($type);
// Add a body field.
node_add_body_field($type);
variable_set('og_group_type_' . $type_name, TRUE);
og_ui_node_type_save($type_name);
}
One option would be to use Drupal's drupal_form_submit() function to programmatically submit the necessary forms. It may be a bit tedious and not be as straightforward as using an API, but it should work.
When I've Search my listing i'm getting some results with pagination, but when i go for second page my search is
breaking as it was a get request where i'm getting the search results via post method.
Note: For getting search results I don't want to submit the form via get request (i.e. Query string params) and also don't want to store the form data in session
Is there any way to get the results which satisfy the above conditions ?
You want to implement the PRG Pattern.
Post/Redirect/Get (PRG) is a web development design pattern that
prevents some duplicate form submissions, creating a more intuitive
interface for user agents (users). PRG implements bookmarks and the
refresh button in a predictable way that does not create duplicate
form submissions.
The CakeDC Search plugin makes that pretty easy to do in CakePHP.
It would be very hard to do it using only "POST" calls. You'll need to transfor your POST into a GET call.
Check this post i made or clone it from github
Hope this helps
EDIT:
Using my git repo. If you want url querystrings instead of named parameters:
in this line, instead of the foreach build the querystring and pass it to the redirect
in this line, get the parameters from the query string ($GET)
and in this line add page, sort and direction to this->paginate
I haven't tested it, but it should be something like that
We can do it with a patch.
In Views :
create search form :
$this->Form->create('Search', array('url' => array('controller' => 'controller', 'action' => 'index', substr(time(), 2,rand(1, 7) ))) );
Note : A random number appended at the end of the form action. This will let us know when to clear session.
in Controller :
public function index( $search = null)
{
$conditions = array(1 => 1);
if( !empty($this->data['Search']['keyword']) && $search)
{
$conditions = array('Model.field like' => $this->data['Search']['keyword'] . '%');
// store search array in session
$this->Session->write('conditions', $this->data['Search']);
}
if ($search)
{
$this->request->data['Search'] = $this->Session->read('conditions');
$conditions = array('Model.field like' => $this->data['Search']['keyword'] . '%');
}
else
{
$conditions = array(1 => 1);
$this->Session->delete('conditions');
}
$this->paginate= array('limit'=> 10, 'conditions' => $conditions);
$lists = $this->Paginate('Model');
}
Hope you understand the logic behind.
I am using ubercart on drupal 7.The ubercart version is 3.x. I have tried to search a lot for a hook which runs after payment is successful.I want to insert few more details to the DB after that.
Is there any hook for complete and successful payment.
I believe most of projects would involve some work after payment so there has to be a hook or way to do it.
Thanks to all
Smith
Use hook_uc_order() (documentation) with $op = 'save' case. And check $order->order_status for the status of the order.
Using hook_uc_order the conditions needed to figure out when an order is successfully completed are:
$op == 'update'
$order->order_status == 'payment_received'
$arg2 == 'completed'
I am unsure if #2 is absolutely needed, but it doesn't seem to hurt.
So this code will let you act when an order is successfully completed:
function MODULE_NAME_uc_order($op, $order, $arg2) {
if($op == 'update' && $order->order_status == 'payment_received' && $arg2 == 'completed'){
//do something on successful order completion
}
}
I do not think there is a specific hook for this, instead use rules and actions, simply create an action as per the code below, then go to configuration, workflow, rules and add your action to the existing rule "Update order status on full payment" or create a separate rule making sure you add a condition to check that the value order:payment-balance is <= 0.
/**
* Implements hook_rules_action_info().
*
* Add rules action to process order after payment
*/
function my_module_rules_action_info() {
$order_arg = array(
'type' => 'uc_order',
'label' => t('Order'),
);
$actions['my_module_action_process_order'] = array(
'label' => t('My Module Process Ubercart Order'),
'group' => t('My Module'),
'base' => 'my_module_action_process_order',
'parameter' => array(
'order' => $order_arg,
),
);
return $actions;
}
function my_module_action_process_order($order) {
// Do Whatever Here
}