Jump to content
  • 0

Bug In The Ajax Boxes Order Form Template


ModulesBakery

Question

15 answers to this question

Recommended Posts

  • 0

The AJAX order templates are not designed to support applying credits. If you want clients to be able to pay via credits on their account, you should use the Standard or Wizard templates instead.

That does not make any sense, a feature included in a template shall be included with all others specially something like that ?

Link to comment
Share on other sites

  • 0

The AJAX templates have a different flow through the order process than the other templates since they handle everything from, essentially, one page. This design doesn't allow for universal support for that feature across all templates.

 

Not every template can, or should, support all features from other templates. For instance, neither the Wizard nor AJAX templates support Client Registration order types.

Link to comment
Share on other sites

  • 0

The AJAX templates have a different flow through the order process than the other templates since they handle everything from, essentially, one page. This design doesn't allow for universal support for that feature across all templates.

 

Not every template can, or should, support all features from other templates. For instance, neither the Wizard nor AJAX templates support Client Registration order types.

but i think it deserve a deep look and some times/hours to find a working solution . the pay with credit is a important thing that we have already requested , and was released -- thanks for this -- , but it has no sense that this feature is not exist is most used order from template !!!

Link to comment
Share on other sites

  • 0

inever checked or tried to do something with the order form .

but normally , in the ajax form , when user log in , why not to include a request to check his credit , if he has a credit include it in a hidden input until he arrive to the payment proccess .

because is really i don't know what is the obstacle in this case .

Link to comment
Share on other sites

  • 0

after a deep look in the code , i think i have a tip todo  . what i will do is to make the credit as no-marchent payment with id "apply_credit" , in the proccess  if the gateway_id is apply_credit , then i call the apply credit function .
 
in getPaymentOptions()
 
i will add in the  end smething like

$total_credit = new stdClass() ;
  // Require login to proceed
  if ($this->client) {
   $credit = $this->Transactions->getTotalCredit($this->client->id, $currency);
   if ($credit > 0) {  
    $total_credit->id ="apply_credit";  
    $total_credit->name ="Pay With Credit ( " . $credit .  $currency .")" ;  
    $total_credit->type ="nonmerchant";  
    $nonmerchant_gateways[] = $total_credit;  
   } 
  }

i will try to make it working
 
EDIT :
 
got it to work in the fetch credit for client (i have discovered a bug , i will report it now :)  )
 
attached a creenshoot for what i have get as result .
 
10079apply_credit_ajax.png

Link to comment
Share on other sites

  • 0

Do you have a suggestion on how this should work? I don't remember the exact conversation internally, but we opted not to include it in the AJAX templates for a particular reason.

 

 

with my actual code , the ajax form send the request to gateway called "apply_credit" .

 

now the solution is one of this two :

 

1 - create a gateway for apply with credit  ( i think this is not a complecated task , but now is 02:11 and my eyes is almost closed .

 

2 - add a check post before sending the request to gateway class .

 

 

NOTE : my goal is not to create a hack or a custom solution , the main goal is to achieve a working solution to implement it in the core files for next releases .

Link to comment
Share on other sites

  • 0

i have got it , now i have working soltion with a minimal file change . now i list my change hack  .

 

in file : Order_Form_Controller.php , in  fucntion getPaymentOptions .

 

search

return compact("nonmerchant_gateways", "merchant_gateway", "payment_types", "currency");

replace with

// Require login to proceed with credit payment
  if ($this->client) {
   $total_credit = new stdClass() ;
   $credit = $this->Transactions->getTotalCredit($this->client->id, $currency);
   if ($credit > 0) {  
    $total_credit->id ="apply_credit";  
    $total_credit->name ="Pay With Credit ( " . $credit  .  $currency .")" ;  
    $total_credit->type ="nonmerchant";  
    $nonmerchant_gateways[] = $total_credit;  
   } 
  }
 
  return compact("nonmerchant_gateways", "merchant_gateway", "payment_types", "currency");

in controllers/checkout.php , in function complete

 

 

search

if (isset($this->get['gateway']))
   $this->setNonmerchantDetails($order, $invoice, $this->get['gateway']);

replace

if (isset($this->get['gateway'])) {
 
   if ($this->get['gateway'] == "apply_credit") {
    $amount_applied = $this->applyCredit($invoice);
   
    // Refetch the invoice
    if ($amount_applied !== false) {
     $invoice = $this->Invoices->get($invoice->id);
    
     // Redirect straight to the complete page if the credits took care of the entire invoice
     if ($invoice->due <= 0 && $invoice->date_closed !== null) {
      $this->redirect($this->base_uri . "order/checkout/complete/" . $this->order_form->label . "/" . $order->order_number . "/");
     }
    }
   }   
   else    
    $this->setNonmerchantDetails($order, $invoice, $this->get['gateway']);
   
  }

enjoy your blesta system :)

 

 

I HOPE THIS CAN BE IMPLEMENTED IN THE OFFICIAL RELEASE .

Link to comment
Share on other sites

  • 0

I don't think your solution is something we'd be able to use. It's generally bad design to override existing fields (i.e. non-merchant gateways) to inject special-case alternate functionality (i.e. credits). I'd also be curious to know how your solution affects the Wizard and Standard templates considering they already handle credits.

Link to comment
Share on other sites

  • 0

I don't think your solution is something we'd be able to use. It's generally bad design to override existing fields (i.e. non-merchant gateways) to inject special-case alternate functionality (i.e. credits). I'd also be curious to know how your solution affects the Wizard and Standard templates considering they already handle credits.

the important here is a solution for this case , is not important mine or your's code , the important is find a solution or a way to do it .

for wizard or standard template i have not tested , but i will . also i'm sure there is a solution , the flexible code of blesta can do this task .

for overriding fileds , that is not true , i have just assigned a velue to imput and then i have get it with condition statement .

at least test it and see the result , and design a good code to implement .

Link to comment
Share on other sites

  • 0

I don't think your solution is something we'd be able to use. It's generally bad design to override existing fields (i.e. non-merchant gateways) to inject special-case alternate functionality (i.e. credits). I'd also be curious to know how your solution affects the Wizard and Standard templates considering they already handle credits.

 

I think that Naja7host posted that solution (regardless of how good it is) as a temporary solution for other Blesta users to use till you decide to solve this and re-design the order forms to support paying using the credit.

Link to comment
Share on other sites

  • 0

I'd also be curious to know how your solution affects the Wizard and Standard templates considering they already handle credits.

i have got what you want to say .... in the standard and wizard template , it get a nother radio box of credit , that mean two option to pay with the credit .

this is because you don't use a unified "total_credit" function for all . the total_credit is coded inside the index function . this index is not used in ajax template .

the solution is :

1 - add the total_credit to the summary function , and change in the template view summary.pdt .

2 - add it inside getPaymentOptions() as a new var "credit" , to be available in all template . (of course this will need a some change in pdt file

but this is not a probleme , i have the solution for that :) , i will update the code when i get time to work in it this weekend .

as @ModulesBakery say , the important for us is to find a way to support paying using the credit in all templates .

you said in your post n5 there is no way to do it .

i demonstrate in my previos post blesta can do it :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...