Skip to content

Instantly share code, notes, and snippets.

View J2112O's full-sized avatar

Josh Otwell J2112O

View GitHub Profile
add_action( 'woocommerce_display_product_attributes', 'woo_custom_variation_display', 12 );
function woo_custom_variation_display( $product_attributes ) {
global $product;
// make sure this is a variable product. If not, return
if ( ! $product->is_type( 'variable' ) ) return;
if ( isset( $product_attributes[ 'attribute_pa_color' ] ) ) {
$variations = $product->get_available_variations( 'object' );
add_action( 'woocommerce_single_product_summary', 'woo_custom_editor_block_field_display', 12 );
function woo_custom_editor_block_field_display() {
global $product;
$example_block_property = $product->get_meta( 'example_block_property' );
if ( empty ( $example_block_property ) ) return;
echo sprintf( __( 'Example Block Property: %s', 'astra-child' ), $example_block_property );
}
use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
if ( ! function_exists( 'woo_prod_editor_custom_add_block' ) ) {
/**
* Add a new block to the template after the product name field.
*
* @param BlockInterface $product_name_field The product name block.
*/
function woo_prod_editor_custom_add_block( BlockInterface $product_name_field ) {
SELECT t.id, t.start_segment, t.end_segment,
SUM(t.one_lag) OVER(ORDER BY t.id ASC) AS rolling_sum
FROM
(SELECT
id, start_segment, end_segment,
IFNULL(LAG(segment_length, 1) OVER(ORDER BY id ASC), 0) AS one_lag
FROM coords_measure) AS t;
SELECT t.id, t.start_segment, t.end_segment,
SUM(t.one_lag) OVER(ORDER BY t.id ASC) AS rolling_sum
FROM
(SELECT
id, start_segment, end_segment,
LAG(segment_length, 1) OVER(ORDER BY id ASC) AS one_lag
FROM coords_measure) AS t;
SELECT
id, start_segment, end_segment,
SUM(LAG(segment_length, 1) OVER(ORDER BY id ASC)) OVER(ORDER BY id ASC) AS one_lag
FROM coords_measure;
Error Code: 3593. You cannot use the window function 'lag' in this context.
SELECT
id, start_segment, end_segment,
LAG(segment_length, 1) OVER(ORDER BY id ASC) AS one_lag
FROM coords_measure;
SELECT
id, start_segment, end_segment,
SUM(segment_length) OVER(ORDER BY id ASC) AS rolling_sum
FROM coords_measure;
mysql> SELECT last_update, DATE(last_update)
-> FROM category
-> LIMIT 5;
+---------------------+-------------------+
| last_update | DATE(last_update) |
+---------------------+-------------------+
| 2006-02-15 04:46:27 | 2006-02-15 |
| 2006-02-15 04:46:27 | 2006-02-15 |
| 2006-02-15 04:46:27 | 2006-02-15 |
| 2006-02-15 04:46:27 | 2006-02-15 |
SELECT category_id, name
FROM category
WHERE category_id NOT BETWEEN 1 AND 5;