Mark C Posted July 22, 2022 Share Posted July 22, 2022 Is there a way to have COD Payment for specified customer? I understand that the buyer will signup on the website. thanks Link to comment Share on other sites More sharing options...
ComGrafPL Posted July 22, 2022 Share Posted July 22, 2022 Maybe create a new group and assign client/s to it. Then set COD only for that specific group? Link to comment Share on other sites More sharing options...
Ali Samie Posted July 22, 2022 Share Posted July 22, 2022 By "specified customer", do you mean a single customer or a selection of customers? Link to comment Share on other sites More sharing options...
Mark C Posted July 22, 2022 Author Share Posted July 22, 2022 Just now, stifler97 said: By "specified customer", do you mean a single customer or a selection of customers? selection of customers Link to comment Share on other sites More sharing options...
Ali Samie Posted July 22, 2022 Share Posted July 22, 2022 Similar question and answer is here, the solution is as @ComGrafPL said. You should restrict COD as a payment module for a group of customers. But it depends what COD are you talking about. They may or may not have this feature. Link to comment Share on other sites More sharing options...
Mark C Posted July 22, 2022 Author Share Posted July 22, 2022 thanks for this. Another problem is i can't see the free add-on for COD Payment. Link to comment Share on other sites More sharing options...
Mark C Posted July 22, 2022 Author Share Posted July 22, 2022 2 minutes ago, Mark C said: thanks for this. Another problem is i can't see the free add-on for COD Payment. sorry . i already saw it. thanks for the help! Link to comment Share on other sites More sharing options...
Ali Samie Posted July 22, 2022 Share Posted July 22, 2022 Found it! In any payment module there should be a method called hookPaymentOption This method returns a payment option to be added to the list of available payment options for customer. If you return an empty array, then this payment options is not available for the customer. So, you need to check customer group at the end of this method. And then if your conditions are not satisfied, you want to simply return an empty array. A simple workaround for this problem in the module ps_wirepayment is here for you: Just add these lines at the end of hookPaymentOption before last line: $currentCustomerGroups = Customer::getGroupsStatic($this->context->customer->id); $allowedCustomerGroups = [1,2,3]; if(empty(array_intersect($currentCustomerGroups, $allowedCustomerGroups))) { return []; } The final result for ps_wirepayment version 2.1.3 is: public function hookPaymentOptions($params) { if (!$this->active) { return []; } if (!$this->checkCurrency($params['cart'])) { return []; } $this->smarty->assign( $this->getTemplateVarInfos() ); $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay by bank wire', [], 'Modules.Wirepayment.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', [], true)) ->setAdditionalInformation($this->fetch('module:ps_wirepayment/views/templates/hook/ps_wirepayment_intro.tpl')); $payment_options = [ $newOption, ]; $currentCustomerGroups = Customer::getGroupsStatic($this->context->customer->id); $allowedCustomerGroups = [1,2,3]; if(empty(array_intersect($currentCustomerGroups, $allowedCustomerGroups))) { return []; } return $payment_options; } As you can see in this code, $allowedCustomerGroups is a hard coded array. You can develop your own form in BO to fill this array dynamically. Link to comment Share on other sites More sharing options...
Mark C Posted July 27, 2022 Author Share Posted July 27, 2022 (edited) i think the grouping of customers is enough for my client. done on this issue by creating a group of users for COD payment. Along with the COD module installation. Edited July 27, 2022 by Mark C (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now