Skip to content

Instantly share code, notes, and snippets.

@becomevocal
becomevocal / paypal-pay-later.tsx
Created December 23, 2024 17:36
PayPal Pay Later component for Catalyst
'use client';
// [>] Developer Notes
//
// * Made for use with Catalyst, by BigCommerce: https://www.catalyst.dev/
//
// * Requires NEXT_PUBLIC_PAYPAL_CLIENT_ID env var
// - By default it will fall back to 'test' if not set, which uses the non-transacting PayPal sandbox
// - You can get your PayPal Client ID here: https://developer.paypal.com/dashboard/applications/live
//
@becomevocal
becomevocal / example.php
Created June 20, 2019 22:37
BC4WP: GeoIP Channel Activation
add_filter( 'bigcommerce/channels/enable-multi-channel', '__return_true' );
if (function_exists('geoip_detect2_get_info_from_current_ip')) {
$userInfo = geoip_detect2_get_info_from_current_ip();
if ($userInfo->country->isoCode == 'FR') {
add_filter( 'bigcommerce/channel/current', function( $channel ) {
// logic to set the channel
return get_term( 41, \BigCommerce\Taxonomies\Channel\Channel::NAME );
}, 10, 1 );
@becomevocal
becomevocal / style.css
Created June 20, 2019 12:16
Region Selector Styles
.languagepicker {
background-color: #FFF;
display: inline-block;
padding: 0;
height: 40px;
overflow: hidden;
transition: all .3s ease;
margin: 0 50px 10px 0;
vertical-align: top;
position: absolute;
@becomevocal
becomevocal / selector.php
Last active June 21, 2019 00:21
Region Selector PHP
<?
$bc4wp_regions = [
'en' => [
'img' => 'http://i64.tinypic.com/fd60km.png',
'url' => '?region=en',
'label' => 'United States',
],
'fr' => [
'img' => 'http://i65.tinypic.com/300b30k.png',
'url' => '?region=fr',
@becomevocal
becomevocal / Customer.php
Created February 6, 2019 21:29
Adding customer group info and category details method to BC4WP customer class (/src/BigCommerce/Accounts/Customer.php)
<?php
namespace BigCommerce\Accounts;
use Bigcommerce\Api\Client;
use Bigcommerce\Api\Resource;
use Bigcommerce\Api\Resources\Address;
use Bigcommerce\Api\Resources\Order;
use Bigcommerce\Api\Resources\OrderProduct;
use BigCommerce\Container\Cli;
class Customer {
const CUSTOMER_ID_META = 'bigcommerce_customer_id';
@becomevocal
becomevocal / functions.php
Created February 6, 2019 15:36
BC4WP: Support for Customer Group Category Visibility (add to bottom of theme functions.php)
use BigCommerce\Accounts\Customer;
const GUEST_CUSTOMER_GROUP_ID = 2;
// Check if transient is set for the guest customer group details. If not, fetch them and store as a transient for 24 hours.
// https://codex.wordpress.org/Transients_API
if ( !get_transient( 'guest_customer_group_category_access' ) && GUEST_CUSTOMER_GROUP_ID !== 0 ) {
$customer = new Customer();
$customer_group_category_access = $customer->get_customer_group_category_access(GUEST_CUSTOMER_GROUP_ID);
set_transient( 'guest_customer_group_category_access', $customer_group_category_access, DAY_IN_SECONDS );