8 – How pass parameters to a custom service?

is possible to pass dynamic params when calling a (custom) service?

For example:
mymodule.services.yml

services:
  my_module.default:
    class: DrupalservicesDefaultService
    arguments: ('@entity_type.manager')

DefaultService.php:

<?php

namespace Drupalmy_module;
use DrupalCoreEntityEntityTypeManagerInterface;

/**
 * Class DefaultService.
 */
class DefaultService implements DefaultServiceInterface {

  /**
   * DrupalCoreEntityEntityTypeManagerInterface definition.
   *
   * @var DrupalCoreEntityEntityTypeManagerInterface
   */
  protected $entityTypeManager;

  private $myValue;

  /**
   * Constructs a new DefaultService object.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;

    //how set $myValue?
    // $this->myValue = ???
  }

}

Is there a way to dynamically set the “myValue” when calling this service – e.g. while calling the service in a hook_ENTITY_TYPE_update, passing the $entity->id() value ?

I’ve found some similar question such as this or this but they don’t answer my problem.

sharepoint online – Custom Communications Template with right column

The default Communications template Hero display occupies the full length of the page and has one large image block on the left half of the page, and 4 small image blocks on the right half of the page. However, we want a default Communication template with the Hero blocks occupying 2/3 of the page, and have Events occupying 1/3 of the page length. Is this possible?

The default Communications template Hero display occupies the full length of the page and has one large image block on the left half of the page, and 4 small image blocks on the right half of the page. When I add a new template through SPO Powershell commands, I can define the colors with a theme, and define navigation options. Question: Can I define a different homepage layout? We would like a default Communication template with the Hero blocks occupying 2/3 of the page length, and have Events occupying 1/3 of the page length. Is this possible?

Add custom price to child product of bundle

I have used this solution to add bundle product in the cart but I also want to change the price of the child products

How to add bundle product to cart programmatically with custom price and quantity (of all products) in Magento 2?

The product with his children are getting add only I want to change the price of each child

Magento 2 – How to add custom attribute to sales/order/view?

How can I add a custom field to sales/order/view in adminhtml?

I want to save a tracking number related to the order.

Thanks.

Why are custom printed boxes good for your business? – Social Media Marketing (SMM)

Hair extensions are the new rage in the fashion world. With the emergence of this new wave in the fashion world, makeup manufacturers have become engrossed in a race to come on top of the other to become the number one brand in this product’s market. For this purpose, they try to encase their product in as much alluring and enticing packaging as possible. Hair Extension Boxes are available in all shapes and sizes, additional window panes allow the customer to have a look inside at the original product which is very helpful and attractive. The diversity in style and designs of these boxes makes them stand out from the rest of the packaging items.

.

magento2 – How to display reviews and ratings on my custom template?

I would like to display reviews and ratings on my custom template.

I can see that Magento_Review/templates/product/view/list.phtml is the one that is in charge of displaying these items.

How can I call list.phtml and pass my product id to display reviews and ratings?

magento2 – Magento 2.3.4 JS Uncaught ReferenceError with custom payment method

I could need some help.

I’ve added a custom payment method to our shop following this tutorial:
https://webkul.com/blog/create-custom-payment-method-magento2/

So far so good, but after loading the checkout page we get the following error:

Uncaught ReferenceError: Unable to process binding "if: function(){return quoteIsVirtual == 0 }"
Message: Unable to process binding "if: function(){return isIncludingDisplayed() }"
Message: Unable to process binding "if: function(){return haveToShowCoupon() }"
Message: haveToShowCoupon is not defined
    at if (eval at createBindingsStringEvaluator (eval at require.load (b1654aa9974d62289672a4f5a5a23090.min.js:1)), <anonymous>:3:55)
    at ko.computed.disposeWhenNodeIsRemoved (eval at require.load (b1654aa9974d62289672a4f5a5a23090.min.js:1), <anonymous>:373:702)
    at Function.evaluateImmediate_CallReadThenEndDependencyDetection (eval at require.load (b1654aa9974d62289672a4f5a5a23090.min.js:1), <anonymous>:205:240)

Here is a simmilar problem: Uncaught ReferenceError: Unable to process binding “if: function(){return isExcludingDisplayed() }” After Magento 2.3.4 Upgrade Checkout Cart Page

The thing is i have’nt altered the shipping.js files.
And when i remove the payment method, the checkout is back in his normal state.

Does someone have an idea what file could have such an impact? Or where i could look to fix it? Or if you need more information, ask. I’ll try to give you as many as possible.

Thanks in Advance!

angular8 – Angular 8 Interceptor resolve custom request not working

I have an issue, with Angular 8 interceptor.
After upgrade from Angular 4 to Angular 8 I needed to recode things, the problem is that I don’t understand why this adaptation is not working inside Interceptor where I am returning the new Observable from my moded function _asyncResponse().

What the code is trying to do is a retroactive function call to prevent chrome 2 minutes timeout calls.
So when it reaches the end (percent === 100) in Retroactive Function (see function below) it should resolve all the function to up and return the custom call wich contains the final response.
It reaches the end but inside .pipe(map()) is not returning the result. it stops and if I change it to .pipe(tap()) or .do() it will return the result at first call loop where I don’t have the response.

As I confirm in Angular 4 work well, but I don’t know how to adapt it correctly to Angular 8. I Would appreciate your help, thanks.

This is how I call them:

this.service.test().subscribe((response: any) => {
    asynchronousResponse(response).then(result => {
            // something with result
        });
    });
});
export const asynchronousResponse = (response: any): Promise<any> => {
    return new Promise<any>(resolve => {
        if (response instanceof PromiseObservable) {
            response.toPromise().then(result => { resolve(result); });
        } else {
            resolve(response);
        }
    });
};

INTERCEPTOR Angular 4 (Works):

public responseIntercept(observable: Observable<Response>): Observable<Response> {
    return observable.map((response: any) => {
        const async = this._asyncCall(response.headers);
        if (async) {
            return this._asyncResponse(async);
        } else {
            return response;
        }
    }).catch((error) => {
        this.loaderService.hide();
        return Observable.throw(error); // here, response is an error
    });
}
 private _asyncResponse(async: any): Observable<Response> {
    const resourceUrl = getAppResourceUrl(async.app);
    setTimeout(() => {
        async.timeout = true;
    }, this.ASYNC_LIMIT_TIMEOUT);
    return toObservable(new Promise((resolve, reject) => {
        this._asyncRetroactive(resourceUrl, async, 0).then((response) => {
            resolve(response);
        }, (error) => {
            reject(error);
        });
    }));
}

INTERCEPTOR Angular 8:

public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<any> {
    return next.handle(req).pipe(
        map((response: HttpEvent<any>) => {
            if (response instanceof HttpResponse) {
                const async = this._asyncCall(response.headers);
                if (async) {
                    return this._asyncResponse(async);
                } else {
                    return response;
                }
            }
        }), catchError((error: any) => {
            this.loaderService.hide();
            return throwError(new Error(error));
        })
    );
}

private _asyncResponse(async: any): Observable<any> {
    const resourceUrl = getAppResourceUrl(async.app);
    setTimeout(() => { async.timeout = true; }, this.ASYNC_LIMIT_TIMEOUT);
    return from(
        Promise.resolve(
            new Promise((resolve, reject) => {
                this._asyncRetroactive(resourceUrl, async, 0).then(response => {
                    resolve(response);
                }, (error: any) => {
                    reject(error);
                });
            })
        )
    );
}

Retroactive function

private _asyncRetroactive(resourceUrl: string, async: any, calls: number): Promise<any> {
    return new Promise((resolve, reject) => {
        const options = createRequestOption({}, 'text');
        this.http.get(resourceUrl + 'api/async/' + async.id, options).toPromise().then((response: any) => {
            console.log('Call: ' + calls);
            calls++;
            const percent = this._asyncStatus(response.headers);
            if (percent === 100 || percent === undefined) {
                console.log('Task complete');
                console.log(response);
                resolve(response);
            } else {
                if (!async.timeout) {
                    // Entre petición y petición esperamos 0.5 segundos para no sobrecargar el servidor a llamadas innecesarias
                    setTimeout(() => {
                        this._asyncRetroactive(resourceUrl, async, calls).then(r => {
                            resolve(r);
                        });
                    }, calls < 5 ? 500 : 1000);
                } else {
                    reject('AsyncInterceptor.timeout');
                }
            }
        }, error => {
            reject(error);
        });
    });
}

ssl – Traefik Lets encrypt and https redirection does not work without custom http challenge request exclusion

Here is what I want with traefik:

  • https redirection
  • let’s encrypt ssl certificate generation
  • for a brand new domain

Here is what happens

  • Traefik makes a request to create a new certificate for a domain using http challenge
  • Let’s encrypt makes request to domain name for http challenge
  • traefik redirects http to https
  • there is not yet a certificate created
  • certificate creation fails

So what I need is some way to exclude the http challenge from let’s encrypt from the http to https redirection but I cannot find out which version traefik. I have checked debug logs but the http challenge url isn’t logged.

here’s the logs

time="2020-10-21T14:55:01Z" level=debug msg="legolog: (INFO) (my.domain.com) acme: Obtaining bundled SAN certificate"

TLS Challenge Present temp certificate for my.domain.com" providerName=acme

time="2020-10-21T14:55:17Z" level=debug msg="TLS Challenge CleanUp temp certificate for my.domain.com" providerName=acme
time="2020-10-21T14:55:17Z" level=debug msg="legolog: (INFO) Deactivating auth: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/137315186"
time="2020-10-21T14:55:17Z" level=debug msg="legolog: (INFO) Unable to deactivate the authorization: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/137315186"
time="2020-10-21T14:55:17Z" level=error msg="Unable to obtain ACME certificate for domains "my.domain.com": unable to generate a certificate for the domains (my.domain.com): error: one or more domains had a problem:n(my.domain.com) acme: error: 400 :: urn:ietf:params:acme:error:connection :: Timeout during connect (likely firewall problem), url: n" routerName=sdlc-sdlc-hub-https-949014c8fdb9352a2ed9@kubernetescrd rule="Host(`my.domain.com`)" providerName=default.acme

The logs indicate that there is supposed to be a temporary certificate used for the challenge but it apparently does not actually work.

If I remove the https redirection for a new domain then re-add it, it works fine, but that is not a great solution if you’re trying to automate things.

8 – Custom ordering flow

I was wondering if it’s possible to replace the default commerce flow with my own custom flow.

As far as I know the default flow is following:

  • Add individual products to cart on Product’s detail page or in Products View
  • Go to cart and proceed to checkout
  • Add shipping & billing information
  • Complete the payment

My flow need to be a bit different. I would like to create View of Products (my products are entry-tickets for an attraction) where user can select quantity of each Product he would like to purchase. I know this View can be AJAXified to change total price dynamically according to quantity of each product. When customer selects all tickets and quantities I need to send him to second page of my Multi-step webform where he enters shipping & billing information and finally confirms / fullfils the payment. After successful payment confirmation / fullfilment I’d like to display the third page of Multi-step Webform where is only confirmation and “thank you” message.

I’ve read through Commerce 2 documentation and I know how to change Order & Checkout workflows, but I’m not sure if I can use Multi-step Webform where the steps are following (as described above):

  • Step 1: Select quantities of each Product in Products View (10 products in total – ticket types)
  • Step 2: Fill shipping and billing information
  • Step 3: Display confirmation message

The general idea is to skip the cart step where I need to go to cart page and instead realize whole flow as a 3-step Multi-step Webform.

Thanks!