@@ -30,7 +30,7 @@ interface BillingAddress extends Address {
3030 * @throws {Error } If cart does not exist or address validation fails
3131 * @returns {Promise<Address> } The newly created address object
3232 */
33- async function addBillingAddressService <
33+ const _addBillingAddress = async function addBillingAddress <
3434 T extends Address = Address ,
3535 R = BillingAddress
3636> (
@@ -85,7 +85,7 @@ async function addBillingAddressService<
8585 } ) ( addressData , connection ) ;
8686
8787 // Update cart with billing address
88- await hookable ( updateCartWithAddress , {
88+ await hookable ( updateCartWithBillingAddress , {
8989 cartUUID,
9090 addressData,
9191 cart,
@@ -100,7 +100,7 @@ async function addBillingAddressService<
100100 await rollback ( connection ) ;
101101 throw error ;
102102 }
103- }
103+ } ;
104104
105105/**
106106 * Save billing address to database
@@ -126,7 +126,7 @@ async function saveBillingAddress(
126126/**
127127 * Update cart with billing address
128128 */
129- async function updateCartWithAddress (
129+ async function updateCartWithBillingAddress (
130130 cartId : number ,
131131 addressId : number ,
132132 connection : PoolClient
@@ -148,7 +148,7 @@ export const addBillingAddress = async (
148148 addressData : Address ,
149149 context : Record < string , unknown > = { }
150150) => {
151- const result = await hookable ( addBillingAddressService , {
151+ const result = await hookable ( _addBillingAddress , {
152152 cartUUID,
153153 addressData,
154154 ...context
@@ -159,10 +159,7 @@ export const addBillingAddress = async (
159159export function hookBeforeSaveBillingAddress (
160160 callback : (
161161 this : Record < string , unknown > ,
162- ...args : [
163- addressData : Address ,
164- connection : PoolClient
165- ]
162+ ...args : [ addressData : Address , connection : PoolClient ]
166163 ) => void | Promise < void > ,
167164 priority : number = 10
168165) : void {
@@ -172,68 +169,57 @@ export function hookBeforeSaveBillingAddress(
172169export function hookAfterSaveBillingAddress (
173170 callback : (
174171 this : Record < string , unknown > ,
175- ...args : [
176- addressData : Address ,
177- connection : PoolClient
178- ]
172+ ...args : [ addressData : Address , connection : PoolClient ]
179173 ) => void | Promise < void > ,
180174 priority : number = 10
181175) : void {
182176 hookAfter ( 'saveBillingAddress' , callback , priority ) ;
183177}
184178
185- export function hookBeforeUpdateCartWithAddress (
179+ export function hookBeforeUpdateCartWithBillingAddress (
186180 callback : (
187181 this : Record < string , unknown > ,
188- ...args : [
189- cartId : number ,
190- addressId : number ,
191- connection : PoolClient
192- ]
182+ ...args : [ cartId : number , addressId : number , connection : PoolClient ]
193183 ) => void | Promise < void > ,
194184 priority : number = 10
195185) : void {
196- hookBefore ( 'updateCartWithAddress ' , callback , priority ) ;
186+ hookBefore ( 'updateCartWithBillingAddress ' , callback , priority ) ;
197187}
198188
199- export function hookAfterUpdateCartWithAddress (
189+ export function hookAfterUpdateCartWithBillingAddress (
200190 callback : (
201191 this : Record < string , unknown > ,
202- ...args : [
203- cartId : number ,
204- addressId : number ,
205- connection : PoolClient
206- ]
192+ ...args : [ cartId : number , addressId : number , connection : PoolClient ]
207193 ) => void | Promise < void > ,
208194 priority : number = 10
209195) : void {
210- hookAfter ( 'updateCartWithAddress ' , callback , priority ) ;
196+ hookAfter ( 'updateCartWithBillingAddress ' , callback , priority ) ;
211197}
212198
213- export function hookBeforeAddBillingAddressService (
199+ export function hookBeforeAddBillingAddress (
214200 callback : (
215201 this : Record < string , unknown > ,
216202 ...args : [
217- cartUUID : string ,
218- addressData : Address ,
219- context : Record < string , unknown >
203+ cartUUID : string ,
204+ addressData : Address ,
205+ context : Record < string , unknown >
220206 ]
221207 ) => void | Promise < void > ,
222208 priority : number = 10
223209) : void {
224- hookBefore ( 'addBillingAddressService ' , callback , priority ) ;
210+ hookBefore ( 'addBillingAddress ' , callback , priority ) ;
225211}
226212
227- export function hookAfterAddBillingAddressService (
213+ export function hookAfterAddBillingAddress (
228214 callback : (
229215 this : Record < string , unknown > ,
230216 ...args : [
231- cartUUID : string ,
232- addressData : Address ,
233- context : Record < string , unknown >
217+ cartUUID : string ,
218+ addressData : Address ,
219+ context : Record < string , unknown >
234220 ]
235221 ) => void | Promise < void > ,
236222 priority : number = 10
237223) : void {
238- hookAfter ( 'addBillingAddressService ' , callback , priority ) ;
224+ hookAfter ( 'addBillingAddress ' , callback , priority ) ;
239225}
0 commit comments