我正在尝试设置一个 AJAX 函数来清除我的购物车
HTML
<a onclick="clearCart(this)" data-href="/product-page/" data-productID="182">Go to Product</a>
Run Code Online (Sandbox Code Playgroud)
JavaScript
function clearCart(d) {
jQuery(document).ready(function($) {
var productID = d.getAttribute("data-productID");
$.ajax({
url: "addtocart.php",
data: {productID: productID},
type: "post",
success: function(output) {
window.location = d.getAttribute("data-href");
//alert(output);
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
PHP
if(isset($_POST['productID']) && !empty($_POST['productID'])) {
global $woocommerce;
$woocommerce->cart->empty_cart();
//echo $_POST['productID'];
}
Run Code Online (Sandbox Code Playgroud)
结果
解决方案
我自己弄明白了,@MirzaP 也提供了一些帮助
JS
function clearCart(d) {
jQuery.post(
"https://dercampus.ch/wp-admin/admin-ajax.php",
//ajaxurl,
{
"action": "clearcart",
"data": d.getAttribute("data-productid")
},
function(){
window.location = d.getAttribute("data-href");
}
);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 中扩展 HTMLElement 对象的原型main.ts,以便我可以在整个 Angular 6 项目中使用它。
但我得到了Property 'fadeOut' does not exist on type 'HTMLElement'.
HTMLElement.prototype.fadeOut = function(duration: number = 300): Promise<void> {
const keyframes: AnimationKeyFrame[] = [{ opacity: 1 }, { opacity: 0 }];
return new Promise(resolve => {
const animation: Animation = this.animate(keyframes, duration);
animation.onfinish = () => resolve();
});
};
Run Code Online (Sandbox Code Playgroud)
HTMLElement.prototype.fadeOut = function(duration: number = 300): Promise<void> {
const keyframes: AnimationKeyFrame[] = [{ opacity: 1 }, { opacity: 0 }];
return new Promise(resolve …Run Code Online (Sandbox Code Playgroud)我正在使用带有延迟加载页面的 Ionic 3。尝试在页面内的组件中显示模式时,出现以下错误:
No component factory found for CourseEditorComponent. Did you add it to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)
正如你可以看到下面下来,我已经添加了CourseEditorComponent作为entryComponent到courses.modules.ts,其中得到由进口dashboard.modules.ts。
我对 Angular/Ionic 中使用自定义 entryComponents 的方式有什么误解吗?
等级制度
DashboardPage
-CoursesComponent
--CourseEditorComponent
--CourseCreatorComponent
-InstructorsComponent
Run Code Online (Sandbox Code Playgroud)
模块
仪表板.module.ts
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { DashboardPage } from './dashboard';
import { CoursesModule } from "./courses/courses.module";
@NgModule({
declarations: [
DashboardPage
],
imports: [
IonicPageModule.forChild(DashboardPage),
CoursesModule
],
})
export class DashboardPageModule {}
Run Code Online (Sandbox Code Playgroud)
course.module.ts
import { NgModule } from '@angular/core';
import …Run Code Online (Sandbox Code Playgroud) 当用户购买产品并按条带支付时,我在集成自动化工作流程方面遇到了一些困难。我正在使用Firestore和 Cloud Functions。
工作流程
付款存储在“付款”集合中
{ product:<uid of the product> '...', user:<uid of the user> '..', method: 'stripe', token:< Stripe token> {..} }
Run Code Online (Sandbox Code Playgroud)触发云功能(用于收款的 onWrite)
TODO:将文档添加到“用户”集合的文档内的“购买”集合
收费付款
我已经实现了这个工作流程,除了第 4 步和第 5 步,因为我不知道如何在 Cloud Functions 中从 Firestore 检索和添加 DocRef(Firebase Docs 提供了很多关于它如何与 RT 数据库配合使用的示例)
函数/index.js
exports.stripeCharge = functions.firestore
.document('/payments/{payment}')
.onWrite(event => {
const paymentId = event.params.payment;
const payment = event.data.data();
if (!payment || payment.method !== 'stripe' || payment.charge) return;
// 4. Get Product's Price …Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-functions google-cloud-firestore
javascript ×3
angular ×2
ajax ×1
firebase ×1
ionic2 ×1
ionic3 ×1
php ×1
typescript ×1
woocommerce ×1
wordpress ×1