Overrides::amp_enable_button( string $button, int $post_id )

Summary

AMP Enable Button


Description

Enable the AMP submit button when a proper variant has been chosen using array filters.


Parameters

$button

(string) (Required) Button HTML.

$post_id

(int) (Required) Post ID.


Return

(string)


Source

File: src/BigCommerce/Amp/Overrides.php

	public function amp_enable_button( $button, $post_id ) {
		$insert = '[disabled]="' . esc_attr( 'variants' . $post_id . '.allVariants.filter( a => a.options.filter( b => ( keys( variants' . $post_id . '.currentOptions ).filter( key => variants' . $post_id . '.currentOptions[ key ] == b.id && key == b.option_id ? true : false ) ).length ? true : false ).length == a.options.length ? a : false )[0].disabled != false ? \'disabled\' : false' ) . '"';
		$button = str_replace( 'type="submit"', 'type="submit" ' . $insert, $button );

		return $button;
	}

User Contributed Notes

You must log in before being able to contribute a note or feedback.