This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This code retrieves course data from an external API and displays it in the user's | |
* My Account area. A merchant has noticed that there's a delay when loading the page. | |
* | |
* 1) What changes would you suggest to reduce or remove that delay? | |
* I've refactored it to retrieve the data from the API using AJAX, so that this does not block the page. | |
* | |
* 2) Is there any other code changes that you would make? | |
* I'd also make the AJAX call secure (nonce) and move the JS and HTML to separate files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
use Analytics; | |
use Config; | |
use Illuminate\Support\Facades\App; | |
use Spatie\Analytics\Period; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add the following snippet to your theme's functions.php file, or use a plugin like Code Snippets. | |
add_action( 'init', function() { | |
// Only make changes as long as Jilt for WooCommerce is installed and connected to Jilt | |
if ( function_exists( 'wc_jilt' ) && wc_jilt()->get_integration()->is_jilt_connected() ) { | |
// Disable Storefront JS for Phone Order carts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sv_add_filter_for_conditional_add_to_cart_fragments() { | |
// only make changes as long as Facebook for WooCommerce is installed | |
if ( function_exists( 'facebook_for_woocommerce' ) ) { | |
$events_tracker = facebook_for_woocommerce()->get_integration()->events_tracker; | |
$events_tracker->add_filter_for_conditional_add_to_cart_fragment(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'comments_array', function ( $comments_flat, $post_id ) { | |
$post = get_post( $post_id ); | |
// checks if the current post has any restricted content | |
if ( false !== strpos( $post->post_content, '[wcm_restrict' ) ) { | |
if ( ! wc_memberships_is_user_active_member() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_get_product_terms', function ( $terms, $product_id, $taxonomy, $args ) { | |
if ( isset( $_GET['wc_pip_action'] ) && ! empty( $_GET['wc_pip_document'] ) && 'packing-list' == $_GET['wc_pip_document'] ) { | |
$terms = wp_get_post_terms( $product_id, $taxonomy, array( | |
'orderby' => 'parent', | |
'order' => 'DESC', | |
'exclude_tree' => '33', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_rest_prepare_wc_user_membership', function ( WP_REST_Response $response, $post, $request ) { | |
$membership = wc_memberships_get_user_membership( $post->ID ); | |
if ( $membership instanceof WC_Memberships_User_Membership ) { | |
$data = $response->get_data(); | |
$data['notes'] = $membership->get_notes(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_checkout_add_on_get_enabled', function( $value, $checkout_add_on ) { | |
// bail if Memberships is not active | |
if ( ! function_exists( 'wc_memberships_is_user_member' ) ) { | |
return $value; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wc_facebook_feed_generation_interval', function( $interval ) { | |
return HOUR_IN_SECONDS; | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wc_braintree_transaction_data', 'sv_unset_transaction_source', 10, 2 ); | |
/** | |
* Unset the transaction source to prevent authorizations from expiring too soon. | |
* | |
* @param array $request_data The transaction/sale data | |
* @param \WC_Braintree_API_Transaction_Request $request the request object | |
* @return array |
OlderNewer