Skip to content

Instantly share code, notes, and snippets.

View unlocomqx's full-sized avatar
🏠
Working from home

Tuni-Soft unlocomqx

🏠
Working from home
  • Module Dev - Tuni-Soft
  • [object Object]
View GitHub Profile
let reset_next = false // flag used to reset the quantity to the minimal quantity after adding to cart
document.addEventListener("dp-loaded", function () {
const addToCart = ceFrontend.utils.urlActions.actions.addToCart
ceFrontend.utils.urlActions.actions.addToCart = function (e) {
window.dpSaveCustomization().then(function (response) {
if (response) {
var id_customization = getFirstItem(response.id_customizations)
jQuery("[name=\"id_customization\"]").val(id_customization)
reset_next = true
addToCart({}, e)
Possible issue with cloudflare workers caused by a canceled promise
Hi 👋
I'm not entirely sure of the exact cause of this issue but I created a minimal repro. maybe someone can pinpoint the source of the issue.
Here's the repo
https://github.com/unlocomqx/cloudflare-error-1101
Here's the deploy to see the issue directly
https://b8aef2ad.cloudflare-error-1101.pages.dev/db
// To be placed in /themes/[current theme]/assets/js/dynamic/custom.js (create the "dynamic" folder)
window.dp_hook = '[data-widget_type="product-variants.default"]'
window.dp_price_hook = ".ce-product-price span"
$(document).on("dp-loaded", function () {
const addToCart = ceFrontend.utils.urlActions.actions.addToCart;
ceFrontend.utils.urlActions.actions.addToCart = function (e) {
window.dpSaveCustomization(true).then(function (response) {
if (response) {
/**
* Tailwind's Preflight Style Reset
* https://tailwindcss.com/docs/preflight
*
* Why is this here?
* 1. Tailwind doesn't publish their style reset (which is
* derived from modern-normalize).
* 2. TailwindCSS's version of this doesn't work with third-party
* DOM elements that it can't extract.
*/
@unlocomqx
unlocomqx / cypress_test_404_spec.js
Created April 27, 2024 04:03 — forked from paulmwatson/cypress_test_404_spec.js
Testing a 404 page with Cypress
cy.visit('/404')
//=> Test fails
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes but does not test the HTTP code was 404
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes, tests that the HTTP code was 404, and tests page was visited
.dp_group_options_qty .content {
display: grid;
grid-auto-flow: column;
grid-template-rows: 1fr 1fr;
grid-auto-columns: auto;
justify-items: center;
justify-content: start;
column-gap: .5rem;
row-gap: 0;
}
@unlocomqx
unlocomqx / products.php
Created January 30, 2024 19:37
Read option sku
<?php
/** @var $id_product */
/* @var DynamicInputField[] $input_fields */
/* @var $dropdown */
/* @var $dropdown_ref */
use DynamicProduct\classes\models\dynamic_fields\DropDownField;
use DynamicProduct\classes\models\DynamicField;
<?php
// The ID of the current product
/** @var int $id_product */
// The selected combination ID
/** @var int $id_attribute */
// The current selected quantity
/** @var int $quantity */
{** If product has a required customization field **}
{if $product.customizable == 2}
show link
{else}
show cart btn
{/if}
@unlocomqx
unlocomqx / cypress.config.ts
Last active November 29, 2023 17:23
It's something like this
import { defineConfig } from 'cypress';
import { seed } from './cypress/plugins/seed';
import vitePreprocessor from 'cypress-vite';
export default defineConfig({
video: false,
e2e: {
baseUrl: 'http://localhost:5173',
specPattern: '**/*.cy.ts',